convert with flop, rotate and crop not working anymore

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
jtkangas
Posts: 5
Joined: 2015-12-21T05:19:56-07:00
Authentication code: 1151

convert with flop, rotate and crop not working anymore

Post by jtkangas »

Convert with flop, rotate and crop not working anymore as expected, resulting image is not what it used to be.

This used to work with version 6.6.9-7 (Ubuntu 12.04)

Code: Select all

convert -flop -rotate -26 -crop 1372x1212+1730+953 original.jpg new.jpg
With version 6.9.2-4 (Mac OS X) it works if the crop is done separately:

Code: Select all

convert -flop -rotate -26 original.jpg tmp.jpg
convert -crop 1372x1212+1730+953 tmp.jpg new2.jpg
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: convert with flop, rotate and crop not working anymore

Post by dlemstra »

What happens when you execute the command in the correct order?

Code: Select all

convert original.jpg -flop -rotate -26 -crop 1372x1212+1730+953 new.jpg
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
jtkangas
Posts: 5
Joined: 2015-12-21T05:19:56-07:00
Authentication code: 1151

Re: convert with flop, rotate and crop not working anymore

Post by jtkangas »

Same error.
jtkangas
Posts: 5
Joined: 2015-12-21T05:19:56-07:00
Authentication code: 1151

Re: convert with flop, rotate and crop not working anymore

Post by jtkangas »

Following PHP code results same erroneous image Mac OS X (port install php55-imagick), works with Ubuntu 12.04LTS (apt-get install php5-imagick).

Code: Select all

<?php

    $inputfile = 'original.jpg';
    $outputfile = 'output.jpg';

    if(!class_exists('Imagick')) {
        echo "ImageMagick extension missing. Aborting.\n";
        exit(1);
    }

    $imagick = new \Imagick(realpath($inputfile));
    $imagick->flopImage();
    $imagick->rotateImage(new ImagickPixel('#FFFFFF'),-26);
    $imagick->cropImage(1372,1212,1730,953);
    $imagick->writeImage($outputfile);
jtkangas
Posts: 5
Joined: 2015-12-21T05:19:56-07:00
Authentication code: 1151

Re: convert with flop, rotate and crop not working anymore

Post by jtkangas »

And if file is written to temporary file after crop and rotate, it works with Mac (or newer ImageMagick version) as well:

Code: Select all

<?php

    $inputfile = 'original.jpg';
    $tmpfile = 'tmp.jpg';
    $outputfile = 'output2.jpg';

    if(!class_exists('Imagick')) {
        echo "ImageMagick extension missing. Aborting.\n";
        exit(1);
    }

    $imagick = new \Imagick(realpath($inputfile));
    $imagick->flopImage();
    $imagick->rotateImage(new ImagickPixel('#FFFFFF'),-26);
    $imagick->writeImage($tmpfile);

    $imagick = new \Imagick(realpath($tmpfile));
    $imagick->cropImage(1372,1212,1730,953);
    $imagick->writeImage($outputfile);
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert with flop, rotate and crop not working anymore

Post by fmw42 »

I do not see any problem with the following command on IM 6.9.2.9 Q16 Mac OSX

Code: Select all

convert logo: -flop -rotate -26 -crop 200x200+150+150 +repage result.png
jtkangas
Posts: 5
Joined: 2015-12-21T05:19:56-07:00
Authentication code: 1151

Re: convert with flop, rotate and crop not working anymore

Post by jtkangas »

In order to get same result as with previous version +repage needs to be before the crop:

Code: Select all

convert original.jpg -flop -rotate -26 +repage -crop 1372x1212+1730+953 new.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert with flop, rotate and crop not working anymore

Post by fmw42 »

The +repage is supposed to be after -crop to remove the virtual canvas. I see no point in having it before -crop.
Post Reply