Page 1 of 1

convert with flop, rotate and crop not working anymore

Posted: 2015-12-21T05:26:35-07:00
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

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

Posted: 2015-12-21T05:34:30-07:00
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

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

Posted: 2015-12-21T05:37:20-07:00
by jtkangas
Same error.

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

Posted: 2015-12-21T06:45:27-07:00
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);

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

Posted: 2015-12-21T06:55:51-07:00
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);

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

Posted: 2015-12-21T10:18:54-07:00
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

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

Posted: 2016-04-28T01:09:13-07:00
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

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

Posted: 2016-04-28T09:59:09-07:00
by fmw42
The +repage is supposed to be after -crop to remove the virtual canvas. I see no point in having it before -crop.