This content has been marked as final.
Show 11 replies
-
1. Possible to determine image dimensions on cffile upload?
jdeline Mar 23, 2007 9:05 AM (in response to Gregory@ETR)Page 6 of http://www.w3.org/Graphics/JPEG/jfif3.pdf describes the location of the Xdensity and Ydensity fields (2 bytes each) for a JPEG. http://www.martinreddy.net/gfx/2d/GIF87a.txt will tell you similar information about the GIF file format.
If that's too much to digest, get yourself a good custom tag, or wait for native functionality in ColdFusion 8. Google coldFusion "custom tag" "image size" -
2. Re: Possible to determine image dimensions on cffile upload?
ghouser Mar 23, 2007 9:26 AM (in response to Gregory@ETR)Yes, I use a script that will determine the dimensions so I can put the heigth and width into database fields for use laster. I will attach the code I use for you.
-
3. Re: Possible to determine image dimensions on cffile upload?
Abinidi Mar 24, 2007 2:13 AM (in response to ghouser)or...
<cfset image_name ="C:\pathtofile\imagefile.jpg">
<cfscript>
imgFile = createObject("java","javax.swing.ImageIcon").init("#image_name#");
imgFile.getImage();
w = imgFile.getIconWidth();
h = imgFile.getIconHeight();
</cfscript>
<cfoutput>width="#w#" height="#h#</cfoutput>
Adjust code accordingly to what you are doing. -
4. Re: Possible to determine image dimensions on cffile upload?
Newsgroup_User Mar 26, 2007 8:00 AM (in response to ghouser)Abinidi wrote:
> <cfscript>
> imgFile = createObject("java","javax.swing.ImageIcon").init("#image_name#");
> imgFile.getImage();
> w = imgFile.getIconWidth();
> h = imgFile.getIconHeight();
> </cfscript>
this is way cool, man!
do you know if there is a way to check the dimensions of an uploaded
flash (swf) movie ?
--
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com -
5. Re: Possible to determine image dimensions on cffile upload?
cf_dev2 Mar 26, 2007 6:53 PM (in response to Newsgroup_User)>do you know if there is a way to check the dimensions of an uploaded
>flash (swf) movie ?
I have never used it but you might check out FlashInspector.CFC at
http://www.doughughes.net/index.cfm?event=viewEntry&entryId=166 -
7. Re: Possible to determine image dimensions on cffile upload?
Newsgroup_User Apr 1, 2007 10:09 AM (in response to ghouser)Abinidi wrote:
> or...
>
> <cfset image_name ="C:\pathtofile\imagefile.jpg">
>
> <cfscript>
> imgFile = createObject("java","javax.swing.ImageIcon").init("#image_name#");
> imgFile.getImage();
> w = imgFile.getIconWidth();
> h = imgFile.getIconHeight();
> </cfscript>
>
> <cfoutput>width="#w#" height="#h#</cfoutput>
>
>
> Adjust code accordingly to what you are doing.
>
i am trying to use the above code to check for dimensions of uploaded
image and delete the image (through cffile action=delete) if its
dimensions are different from required. the checking part works fine,
but i am unable to delete the image!
CF trows an error:
ColdFusion could not delete the file "[full path to file]\[filename]"
for an unknown reason.
the path is correct, the file is there, and i can delete it manually
without a problem, but not with cffile action=delete...
any ideas? does that have something to do with the instantiated java
object? how do i de-instantiate it?
--
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com -
8. Re: Possible to determine image dimensions on cffile upload?
Newsgroup_User Apr 2, 2007 6:00 PM (in response to ghouser)well, i have come up with a work-around, but would still like to learn
how (if possible) to release a java object invoked with createObject()...
in case anyone is interested, the work-around i implemented is:
add uploaded files of wrong dimensions to a list, after succefful upload
of correct file pass the list to another page which silently loops
through it and deletes the files from server and returns user to
original calling page...
--
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com -
9. Re: Possible to determine image dimensions on cffile upload?
cf_dev2 Apr 27, 2007 1:08 PM (in response to Newsgroup_User)Azadi,
I ran a few tests and cffile delete worked. So I'm not sure what the problem is. I looked at the cfc and it refers to two java classes.
java.io.ByteArrayInputStream
java.util.zip.InflaterInputStream
Both classes have a close() method, though ByteArrayInputStream.close() doesn't do anything. For grins .. you might try adding a function to the FlashInspector.cfc that calls the close() method on the java objects. Then call that function just before attempting to deleting the file. I don't know that it will help but its worth a shot.
-
10. Re: Possible to determine image dimensions on cffile upload?
Newsgroup_User Apr 27, 2007 11:18 PM (in response to Newsgroup_User)thanks for your input, cf_dev2!
i was actually having the problem with getting jpeg dimensions using
Abinidi's code that uses javax.swing.ImageIcon class, not the
FlashInspector.cfc...
the FlashInspector works like a charm... it's the created java object
that would not release and let me delete the jpeg image if its
dimensions are wrong...
i have since switched to using imagecfc from opensourcecf - a lot more
code, but all packed into a cfc, and lets you resize/crop the image to
correct dimensions instead of just telling the user "sorry, your image
is wrong size, please resize and re-upload"...
but thank for your time looking into this, and your url for the
FlashInspector.cfc was a true lifesaver!
--
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com -
11. Re: Possible to determine image dimensions on cffile upload?
cf_dev2 Apr 28, 2007 12:07 AM (in response to Newsgroup_User)> i was actually having the problem with getting jpeg dimensions
Azadi,
Well that's what I get for trying to read before I've had my morning coffee ;-)
Now that I think about it I remember having a similar problem. Either with java.swing.ImageIcon or java.awt.Image or both. But it sounds like imagecfc has solved your problem and it does have some great features.
Until next time then!