• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Resize image and maintain aspect ratio

Participant ,
Oct 19, 2010 Oct 19, 2010

Copy link to clipboard

Copied

Hello all

I'm trying to resize big JPEGs and maintain the aspect ratio. I actually managed to write the code but it is huge so I wonder whether there is an easy way. The next question is regarding the picture resolution. I resize pictures which come in 600 and more dpi. Is there a way ColdFusion can resize and decrease the resolution to 72dpi?

Thanks for hints and links

TOPICS
Advanced techniques

Views

2.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Oct 21, 2010 Oct 21, 2010

tomtomtom wrote:

And these thumbnails come in a resolution of 600 dpi

No they don't.  Files do not have dpi -- OUTPUT (and some INPUT) devices have dpi.

FIles have resolution, color depth, file format and compression.

Your are mixing up OUTPUT quality with FILE data.

You have an image file that is 100px by 100px.  That is the FILE data.  Thus the file has 10,000 pixels of data (not a lot for a picture).

Now if you OUTPUT that to a monitor at 72dpi those 10,000 pixels will be displayed in an area of ~

...

Votes

Translate

Translate
LEGEND ,
Oct 19, 2010 Oct 19, 2010

Copy link to clipboard

Copied

Have you read the docs on imageResize():

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7961.html

?

width

Required. New width of the ColdFusion image.

If this value is blank, the width is calculated proportionately to the height.

height

Required. New height of the ColdFusion image.

If this value is blank, the height is calculated proportionately to the width.

Not too sure about the DPI issue, but have you read over the docs for all the image functions?

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 19, 2010 Oct 19, 2010

Copy link to clipboard

Copied

Dear Adam

Many thanks for your solution - I wasn't reading careful enough the cfimage and resizeimage tutorials! I quickly went through the image functions and unfortunately did not find anything yet regarding my DPI issue...

May be someone else knows something?

Thanks again!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 19, 2010 Oct 19, 2010

Copy link to clipboard

Copied

DPI are reasonably irrelevant as long as you're resizing the images for screen use. DPI is relevant for print though as it describes the "density" of your pixels.

If your images are 600dpi, I would assume tehy have really high resolution, for screen use you just resize them to the pixel dimensions you need.

Also, have a read of this thread re dimensions vs. DPI: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:54696

Cheers

Kai

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 21, 2010 Oct 21, 2010

Copy link to clipboard

Copied

Hello Kai

Many thanks for your post. I checked the posts on houseoffusion.com. It does help understanding all technical issues but actually has not a lot to do with my question. May be I try to ask it in another way:

I'm storing images which are supposed to be printed on a server. So these images need to be in "good quality". The images are initially scanned from dias in a resolution of 600 dpi. I do not want my database application to show the initially scanned images. Imagine I have a page showing 10 pics at the time - I would need to download hundreds of MB. I programmed my CF application to create thumnails in 100 x 100 pixels dimension. And these thumbnails come in a resolution of 600 dpi which does not make any sense because they are intended to be displayed on a screen. So 72 dpi would be enough. Another reason is the size of the thumb. In 600 dpi it is much bigger than if it would come in 72 dpi. So, is there a way to work on the resolution of the image with CF?

Thank you very much for input.

Regards

Tom

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 21, 2010 Oct 21, 2010

Copy link to clipboard

Copied

tomtomtom wrote:

And these thumbnails come in a resolution of 600 dpi

No they don't.  Files do not have dpi -- OUTPUT (and some INPUT) devices have dpi.

FIles have resolution, color depth, file format and compression.

Your are mixing up OUTPUT quality with FILE data.

You have an image file that is 100px by 100px.  That is the FILE data.  Thus the file has 10,000 pixels of data (not a lot for a picture).

Now if you OUTPUT that to a monitor at 72dpi those 10,000 pixels will be displayed in an area of ~1.38 inches by ~1.38 inches.

If you OUTPUT that to a printer at 300dpi it will be displayed in an area of ~0.33 inches by ~0.33 inches.

The quality of the image file is the same, but the output determines how small the dots are for each pixel and thus how large the overall image is.

The things that affect the quality of the image file are how many dots there are in the file (resolution) how much those dots are squeezed (compression) and file format (lossless versus lossy) and how many colors can be used for each dot (color depth)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 21, 2010 Oct 21, 2010

Copy link to clipboard

Copied

LATEST

Hey Tom,

when you create a thumbnail from your original image (having a very high resolution) and that thumbnail is 100x100 pixels, that's all it is to it really. Your thumb will then render 100x100 on the screen and given that the _output_ device screen usually has 72 dpi it'll use the appropriate size in inches.

Your thumbnail would not "have" 600 dpi, there's no such thing defined for image/file data as such. Just create an thumbnail having the resolution you want and need for your web output and you're done.

Hope that makes sense, if not ask.

Cheers

Kai

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation