I'm using the Imagick libray in PHP to do some some image manipulation with imagemagick. The user uploads an photo, I resize it, and then use the compositeImage function to place a transparent PNG layer over it. The code looks roughly like this:
$image = new Imagick($imagepath);
$overlay = new Imagick("filters/photo-filter-flat.png");
$geo = $image->getImageGeometry();
if ($geo['height'] > $geo['width']) {
$image->scaleImage(0, 480);
} else {
$image->scaleImage(320, 0);
}
$image->compositeImage($overlay, imagick::COMPOSITE_ATOP, 0, 0);
return $image;
So the strange thing is, with some photos the overlay gets rotated 90 degrees when it's placed on top. I'm thinking this has to do with different file formats, is there an accepted way to normalize images before you composite them to prevent this?