Search code examples
phpimageimage-processingimagemagickimagick

How can I avoid this line break/image distortion with ImageMagick?


I am testing out using ImageMagick's ability to concatenate image files together for an image sprite creation function for a new project using the imagick PHP extension.

I create the image sprite in chunks of 32 images each, compress the sprite, display each of them in JPEG and WEBP versions and also display an uncompressed WEBP sprite that is not broken down into 32 images per sprite.

So that's what you are looking at below:

enter image description here

And as you can see on the image to the right (sorry for the possibly inflamatory content... they're just random public domain images taken from flickr) which is the non chunked non compressed WEBP version of the sprite.. there is a sharp/obvious line in the center of one of the images in the sprite.

Why is that?

What is it called?

And how can I make it go away?

Thanks in advance!


Solution

  • enter image description here

    That horizontal break in the third picture happens when pieces are first upscaled, then composed. In that case, the upscaling can't look beyond one piece's edge and has to extrapolate, and it does that by doing what you see.

    You need to compose first, then upscale.