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

ImageResize Off by 1px

New Here ,
Mar 05, 2008 Mar 05, 2008

Copy link to clipboard

Copied

When using ImageResize it can be off by 1px in height, width or both. If I specify the "interpolation" as "highestPerformance" it resizes correctly but with "highestQuality" (which is prefered) the image is off 1px.

This doesn't happen every time, it depends on the starting width and height if it is off.

Is there a hot fix for this, is there any way (other than highestPerformance) to get that to work and look good?

Thanks.
TOPICS
Advanced techniques

Views

572

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 ,
Mar 05, 2008 Mar 05, 2008

Copy link to clipboard

Copied

Can you give an example that reproduces this problem?

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
New Here ,
Mar 06, 2008 Mar 06, 2008

Copy link to clipboard

Copied

Sure, no problem.

The image I started with was 1280x960 at 72dpi.

<cfimage source="d:\projects\test.jpg" name="img">
<cfscript>
ImageSetAntialiasing(img, "on");
ImageCrop(img, 66, 270, 458, 229);
ImageResize(img, 100, 50);
</cfscript>
<cfimage source="#img#" action="write" destination="d:\projects\test-thumb.jpg" quality=".85" overwrite="yes">

The user would click on the image to come up with x, y, w and h values.

Thanks for the help

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 ,
Mar 06, 2008 Mar 06, 2008

Copy link to clipboard

Copied

Yes, that seems like a rounding problem. Christian Küpers mentioned something about this on Ben Nadel's blog. I do not know if the math works out in every case, but notice how incrementing the value slightly produces a 100x50 image, instead of 99x49? That seems to support the theory it is a rounding problem.

ImageResize(img, 100.0001, 50.0001);


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
New Here ,
Mar 06, 2008 Mar 06, 2008

Copy link to clipboard

Copied

Yeah, I go to Ben's website to find answeres to most of my problems.

Thanks I just add ".0001" to my variables and it works perfectly. Thanks

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 ,
Mar 06, 2008 Mar 06, 2008

Copy link to clipboard

Copied

Yes, I have read it occaisionally and there are some good entries. I just happened to remember seeing something about resizing problems in the comments when researching how to create transparent gif's. I re-checked google and sure enough, there it was ;-)

Btw, if you do not see any image function fixes in the latest hot fixes, you might consider submitting a bug report on this issue.

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
New Here ,
Mar 06, 2008 Mar 06, 2008

Copy link to clipboard

Copied

I did not see anything related to that so I'll submit it. 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
Valorous Hero ,
Apr 05, 2008 Apr 05, 2008

Copy link to clipboard

Copied

LATEST
Just an update. The issue is now included in the Known Issues section of the Release notes for the recent ColdFusion 8 Update 1.

70069
Sometimes the ImageResize function produces an image 1 pixel shorter or
narrower than the requested size. The image does resize properly if you
specify bicubic, bilinear, nearest, or highestPerformance as the
interpolation parameter value.

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