• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1406
  • Last Modified:

Image dpi

Does anybody know how to detect an image dpi with the new ColdFusion 8 tags, or any other way in ColdFusion.
  • 8
  • 5
  • 2
1 Solution
AFAIK cfimage does not do DPI

the only thing I've come across cfx_imageInfo is http://www.cfmcentral.com/gallery/detail.cfm?Script_ID=52 (open source)

from the docs

"FILE Parameters


        Name of the image file you wish to have information about.


        * ImageInfo ("OK" or blank)
        * ImageInfoError
        * ImageInfoFile
        * ImageInfoType
        * ImageInfoWidth
        * ImageInfoHeight
        * ImageInfoPixels
        * ImageInfoSize
        * ImageInfoPixelBits
        * ImageInfoCompression
        * ImageInfoColors
        * ImageInfoColorType
        * ImageInfoDPI <----------------------------
        * ImageInfoComments "
Good point. Can you use the 'absolute size' since it gives you the height & width in pixels?
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

"Can you use the 'absolute size' since it gives you the height & width in pixels?"

pixel width/height and real world width/height have no relation since a 100px x 100px image at 72dpi can be  the same size as a 100px x 100 px image at 300 dpi

the confusion arises from the improper use of DPI which is a real world thing (ie: number of dots a printer can make on paper or the halftone screen on film) and PPI (pixels per inch) which is it's resolution...

more info here  http://www.kcbx.net/~mhd/2photo/digital/pixel.htm
Oh, I am plenty familiar with real world use, I just don't know what TIO-Solutions has in mind, and in what context his images are being used.

But I am not sure you are 100% correct when you say that:

<<since a 100px x 100px image at 72dpi can be  the same size as a 100px x 100 px image at 300 dpi>>

In this instance, it depends upon how you define size: viewing size or total file size. If you are implying the total file size is the same, I would agree. If you are implying the viewing size is the same, I would say that depends largely upon what the image is being viewed in and would actually NOT be the same in most cases.

If its typical web stuff, you might be able to make the assumption that the files are 72 ppi, but I think we need more info from TIO. I was assuming he was (incorrectly as you pointed out) using DPI and PPI interchangeable, as most people do these days. Its pretty much become standard vernacular.
in what situation would they not be the same size? afaik 100px is 100px

I created 2 jpgs in corelpaint

one at 100px x 100px image at 72dpi and one at 100px x 100 px image at 300 dpi

when printed, they are the same size 0.3333 in. (100x100) however small text is unreadable at 72dpi (meaning that it is in fact dpi and not ppi)

when viewed in a browser, win pic/fax viewer and corel, they are the same size but are affected by the PPI - and are about 1.0625 in (measured on screen) on my 1280x1024 19in monitor. Changing the monitor rez to 800x600 changes the display size of both to 1.625 in

fwiw, I actually asked myself the same thing, could you figure dpi out based on pixels vs file size, but it doesn't seem possible

my 2 files have the following properties

fileA - 72 dpi 100px x 100px 825 bytes
fileB - 300 dpi 100px x 100px 827 bytes

i can't see any way to make any use of that...

Try placing them in an html document and viewing them. The size will be different.

 size is the same (in both FF and IE)

afaik browsers (rightly) ignore dpi. I think they always display at 72 or 96 dpi depending on mac or pc). PPI is all they care about so my 100x100 images are exactly the same even though the dpi is very different.
you know what? I am thinking of something else. You're right.
"I think they always display at 72 or 96 dpi depending on mac or pc"

that's wrong i find.. (even the first source I checked got it wrong... hehe)

it really is PPI

this is as clear an explanation as i've found

"On a web page, only PPI is relevant, and there are 72 PPI on a Mac or a PC screen at "normal" screen resolutions. It doesn't matter what resolution you do your scans or the resolution of your PhotoShop files, a 120 pixel wide graphic will be 120 pixels wide at 72 DPI or at 600 DPI. If you print those files on a laser or ink-jet printer from within your graphics package, then it will be a different story, the 72 DPI will be large and pixelated and the 600 DPI file will be small and crisp. If you print the files from within a web page, what you get is effectively 72 DPI. Period."


TIO-SolutionsAuthor Commented:

Thank you for everybody's responses.

We are a tourist company and we are sourcing images for download to our brands for the purpose of web use and actual brochure use, so they need to see what the resolution is of the image before they download it for use.

ID:20420575 is pretty much what I need, I have however tried to use it before I posted this question but I am getting the following error:

Error occurred in tag CFX_IMAGEINFO  
Unexpected error occurred while processing tag.  
The error occurred in C:\Inetpub\wwwroot\TIOConnect\test.cfm: line 1
1 : <CFX_ImageInfo file="C:\Inetpub\wwwroot\tioconnect\thumb_minitrain.jpg">
3 : <pre>
I got it to work... sort of...

the supplied examples partially work and produce the info below (including dpi)

I'm wondering if you registered the customtag?

cfadmin -> cfx tags -> Register C++ CFX -> name tag cfx_imageinfo -> choose path to dll

    File 	Error 	Type 	Width 	Height 	Pixels 	Size 	PixelBits 	Colors 	ColorType 	Compression 	DPI 	Comments
    c:\inetpub\wwwroot\test\html\16.bmp 		bmp 	443 	333 	147519 	12262 	4 	16 	CLUT16 	RLE 	72 	
    c:\inetpub\wwwroot\test\html\16.pcx 		pcx 	544 	384 	208896 	20708 	4 	16 	CLUT 	PCX Run-length encoding. ZSoft. Version 2.8 w/ palette information. 	72 	
    c:\inetpub\wwwroot\test\html\2.pcx 		pcx 	544 	384 	208896 	5157 	1 	2 	CLUT 	PCX Run-length encoding. ZSoft. Version 2.5 of PC Paintbrush. 	72 	
    c:\inetpub\wwwroot\test\html\24.pcx 		pcx 	544 	384 	208896 	107603 	24 	16777216 	RGB 	PCX Run-length encoding. ZSoft. Version 3.0+ PC Paintbrush. 	72 	
    c:\inetpub\wwwroot\test\html\cfximageinfo.png 		png 	542 	126 	68292 	30847 	24 	16777216 	RGB 	Method 0 (32k sliding window deflate/inflate compression) 	0 	Creation Time
    c:\inetpub\wwwroot\test\html\cmyk.jpg 		jpg 	443 	333 	147519 	29181 	32 	4294967296 		Baseline 	0 	File written by Adobe Photoshop¨ 5.
    c:\inetpub\wwwroot\test\html\cmyk.tif 		tif 	837 	365 	305505 	37924 	32 	4294967296 	CMYK 	LZW (Lempel-Ziv-Welch, Unisys US Patent No 4,558,302) 	72 	IMAGEDESCRIPTION: This is the caption. ARTIST: L.A.Sellers COPYRIGHT: Yo! It's mine!
    c:\inetpub\wwwroot\test\html\fax.tif 		tif 	512 	384 	196608 	3436 	1 	2 	WhiteIsZero 	T4-encoding: CCIT T.4 bi-level encoding 	72 	
    c:\inetpub\wwwroot\test\html\grayscale.jpg 		jpg 	585 	260 	152100 	6309 	8 	256 	Grayscale 	Baseline 	0 	
    c:\inetpub\wwwroot\test\html\packbits.tif 		tif 	512 	384 	196608 	27756 	24 	16777216 	RGB 	Packbits compression 	72 	IMAGEDESCRIPTION: packbits
    c:\inetpub\wwwroot\test\html\test.bmp 		bmp 	443 	333 	147519 	443610 	24 	16777216 	RGB 	None 	72 	
    c:\inetpub\wwwroot\test\html\test.gif 		gif 	500 	200 	100000 	6079 	7 	256 	CLUT 	LZW (Lempel-Ziv-Welch, Unisys US Patent No 4,558,302) 	0 	
    c:\inetpub\wwwroot\test\html\test.jpg 		jpg 	640 	480 	307200 	9092 	24 	16777216 	RGB 	Baseline 	0 	
    c:\inetpub\wwwroot\test\html\test.pcx 		pcx 	544 	384 	208896 	30620 	8 	256 	CLUT 	PCX Run-length encoding. ZSoft. Version 3.0+ PC Paintbrush. 	72 	
    c:\inetpub\wwwroot\test\html\test.png 		png 	1024 	768 	786432 	32054 	24 	16777216 	RGB 	Method 0 (32k sliding window deflate/inflate compression) 	0 	
    c:\inetpub\wwwroot\test\html\test.psd 		psd 	1600 	900 	1440000 	324935 	32 	4294967296 	CMYK 	RLE 	0 	
    c:\inetpub\wwwroot\test\html\test.tga 		tga 	534 	384 	205056 	40279 	24 	16777216 	RGB 	RLE RGB 	0 	
    c:\inetpub\wwwroot\test\html\test.tif 		tif 	1116 	486 	542376 	44846 	24 	16777216 	RGB 	LZW (Lempel-Ziv-Welch, Unisys US Patent No 4,558,302) 	72 	IMAGEDESCRIPTION: This is the caption. ARTIST: L.A.Sellers COPYRIGHT: Yo! It's mine!
18 records

Open in new window

on further testing it appears that the file parameter isn't working??

 folder parameter works (which is what the above is)

however another thing... it appears it can't read dpi on jpg's ...bmps work but shows 0 for jpgs

the version I'm testing has last notes in 1999 so perhpoas it's too old to work correctly... I'll see if i can find a lter version...
ok... the version i had was old

the latest one i found is from


and it seems to work properly no errors and I do get the dpi for jpgs...

1 	16777216 	RGB 	[empty string] 	Baseline 	{ts '2007-12-06 10:20:07'} 	72 	0 	[empty string] 	new2.jpg 	JFIF 	100 	{ts '2007-12-07 08:50:31'} 	{ts '2007-12-06 10:20:09'} 	0 	c:\inetpub\wwwroot\test\new2.jpg 	24 	10000 	825 	[empty string] 	[empty string] 	jpg 	100

Open in new window

TIO-SolutionsAuthor Commented:
Thank you to all, I have solved the problem.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 8
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now