Hi Nitai,
Thank you so much!!! i think I almost have it and at this point, I totally
understand the logic behind this. I'm glad I got a little push to move
imagemagick as it seems like a much better solution. Having it embeded into
oPenBd would be awesome though!
Here is what I have so far. Basically, to make the thumbnail, I want it to
be no more than 100 pixels wide and 90 pixels tall. But I don't want it
conformed to those dimensions, just the lesser of the two. The size is
specific due to design and how it will appear on the page. I would just make
it easy and just declare maximum width, but if I get a photo that is
1000tall and 100wide, even though it meets the width it is still way too
tall. Granted, when the thumbnail is clicked on, the user would get the
original photo, or one that isn't so dramatically reduced one way or
another. Either way, I need to get this working at least to a certain
degree so I can fix some other code and scripts. When I have the time, I'll
take another pass and see if I can't fine tune this process by adding some
switches and being more precise with imagemagick options.
Anyway, here is what I have so far.
<!--- Get Uploaded Image Width and Height --->
<cfexecute
name="identify"
arguments="-format %w #cffile.serverdirectory#/#local_photo_file#"
timeout="10"
variable="image_width"
/>
<cfexecute
name="identify"
arguments="-format %h #cffile.serverdirectory#/#local_photo_file#"
timeout="10"
variable="image_height"
/>
<!--- Check if the image is wider than 100 pixels or taller than 90 pixels
and if so, resize it accordingly--->
<CFIF ((image_width GT 100) OR (image_height GT 90)) and NOT
FileExists("#cffile.serverdirectory#/xs_#local_photo_file#")>
<CFIF image_width GT "#image_height#">
<CFSET Size = "90">
<CFSET width_Percentage = Evaluate(Size / image_width)>
<CFSET width_Percentage = Round(Percentage * 100)>
<CFSET height_Percentage = "">
<CFELSE>
<CFSET Size = "100">
<CFSET height_Percentage = Evaluate(Size / image_height)>
<CFSET height_Percentage = Round(Percentage * 100)>
<CFSET width_Percentage = "">
</CFIF>
<cfexecute
name="convert"
arguments="#cffile.serverdirectory#/#local_photo_file#
-resize #width_percentage#x#height_percentage#
#cffile.serverdirectory#/xs_#local_photo_file#"
timeout="120"
/>
<!--- Check if the image width is less than 100 pixels or height less than
90 pixels and if so, resize it accordingly--->
<CFELSE>
<CFIF image_width LT "#image_height#">
<CFSET Size = "90">
<CFSET width_Percentage = Evaluate(Size / image_width)>
<CFSET width_Percentage = Round(Percentage * 100)>
<CFSET height_Percentage = "">
<CFELSE>
<CFSET Size = "100">
<CFSET height_Percentage = Evaluate(Size / image_height)>
<CFSET height_Percentage = Round(Percentage * 100)>
<CFSET width_Percentage = "">
</CFIF>
<cfexecute
name="convert"
arguments="#cffile.serverdirectory#/#local_photo_file#
-resize #width_percentage#x#height_percentage#
#cffile.serverdirectory#/xs_#local_photo_file#"
timeout="120"
/>
</CFIF>
--
Open BlueDragon Public Mailing List
http://www.openbluedragon.org/ http://twitter.com/OpenBlueDragon
mailing list - http://groups.google.com/group/openbd?hl=en
!! save a network - please trim replies before posting !!