This project has moved. For the latest updates, please go here.

Resize is not working properly

Sep 16, 2014 at 5:15 AM
I am trying to resize (shrink) a .tiff image. The resize is not working properly. It's cropping the image, not resizing it. What is wrong with this code here?
        MagickImage NewImage = new MagickImage(strTempFile);
        NewImage.Resize(750, 256);
        NewImage.Format = MagickFormat.Tiff;
        NewImage.Write(strFileName);
The before is https://boomerangdm.com/Before.tif
The after is https://boomerangdm.com/After.tif
Coordinator
Sep 16, 2014 at 10:12 AM
Resize is working properly but it is not doing what you are expecting. This looks like a rounding error but it isn't. The following page has a great explanation: http://www.imagemagick.org/Usage/resize/#resize. If you specify the width and the height the resized image will fit into the requested size. It does NOT fill, the requested box size. What you could do is first resize the image and the extend the image to the size you want:
MagickImage NewImage = new MagickImage(strTempFile);
NewImage.Resize(750, 256);
NewImage.BackgroundColor = Color.Purple; //This is probably not the best color.
NewImage.Extent(750, 256, Gravity.Center);
NewImage.Format = MagickFormat.Tiff;
NewImage.Write(strFileName);
Sep 16, 2014 at 5:29 PM
Thank you for the reply. I had already tried that and it made no difference, but for purpose of discussion, I went back to it. I did walk through this in debug to be 100% sure it called every line with no errors.

Here is my current code.
        MagickImage NewImage = new MagickImage(strTempFile);
        NewImage.Resize(750, 256);
        NewImage.BackgroundColor = Color.Transparent;
        NewImage.Extent(750, 256, Gravity.Center);
        NewImage.Format = MagickFormat.Tiff;
        NewImage.Write(strFileName);
The after is at https://boomerangdm.com/After2.tif
You can see it made no difference.
Coordinator
Sep 16, 2014 at 9:08 PM
The image is now 750x256 instead of 749x256 and the output looks normal to me? I don't understand what is wrong with the output image.
Sep 19, 2014 at 9:30 PM
Sorry, I have been out of town the last couple of days.

When I open 'after2.tif' in Photoshop, this is what I see? I only see about 1/4 of it, and I am unable to move view any more of it.

https://boomerangdm.com/Result.png
Sep 22, 2014 at 6:08 PM
Hello. Did you have any ideas on this? My user is upset that I don't have any answers on this yet.
Coordinator
Sep 22, 2014 at 9:16 PM
I did some research with the help of someone who has Photoshop. We noticed that you can move the image in Photoshop inside the window. We think we found what is causing it but it is still showing up weird in Photoshop if we 'fix' that, There is 'Adobe Photshop' specific data in the image (http://www.awaresystems.be/imaging/tiff/tifftags/imagesourcedata.html). If you remove that profile the window is normal but the image suddenly becomes dark. It might just be his Photoshop version that is doing this so maybe you could also give it a try? Call image.RemoveProfile("tiff:37724"); before you write the image.
Sep 23, 2014 at 2:16 AM

So far, that appears to have fixed it. I have turned it over to my vendor. Thanks!

Coordinator
Sep 23, 2014 at 4:55 AM
Does it show the transparency checkerboard in Photoshop for you? The person who helped it me test it did not see the checkerboard. What is your Photoshop version?
Sep 23, 2014 at 2:41 PM
I am using the cloud version of Adobe Photoshop 2014.
Coordinator
Sep 23, 2014 at 3:28 PM
Does it show the transparency checkerboard?
Sep 23, 2014 at 3:37 PM
I'm really not a Photoshop expert, I own the cloud version, but I'm not very good at Photoshop. I do not see a transparency checkerboard, but I could be looking in the wrong place.
Coordinator
Sep 23, 2014 at 3:39 PM
Sep 23, 2014 at 3:43 PM

Oh, sorry. My image is a rectangle, so there is no background.

I just erased some of it, and yes, now that background is showing up.