Thumbnail creation from user uploaded images
Posted: 2018-07-22T22:34:55-07:00
Hi,
I am trying to make a program to create thumbnail images from user provided input images. I had some questions regarding how to do this. Generally speaking, I would prefer the images to be small, square images in the same file format as the input image. I am using the MagickWand API, through a Golang wrapper library.
1. What is the the difference between Properties, Profiles, Artifacts and Options? These all appear to be metadata, and there seems to be a lot of overlap in the data exposed here? Are all Profiles color profiles, or are there other kinds? Are all options set by my application, or could they be set by MagickCore when decoding the image? Is it generally safe to remove all of these? The "-strip" option to convert removes *some* of these, but not all of them.
2. I would prefer to drop color profiles, since they seem to be a few KB in size; enough to rival the image data. Is it okay to just convert all thumbnail images to the sRGB color space and depend on browsers to expect images in the sRGB color space?
3. Is it still correct to convert the input image to LAB colorspace (or another perceptually uniform colorspace) before resizing? I would like to avoid any easily avoidable degradation in image quality. From reading online it seems this is the correct way to resize, but perhaps ImageMagick does it already?
My main concern is that when I did this in my code, it didn't make any significant difference in the output thumbnail. I'm wondering if I was just noticing quantization errors due to the colorspace conversion. How do I tell if I did it right? Is there a kind of image that really shows off the difference?
4. Cropping the image down to a square has proved tricky, and I don't think I am doing it right. I am using MagickGetImagePage to get the width and height, and then cropping it down to the largest square that fits inside. The problem is that MagickCropImage doesn't seem to update the ImagePage afterwards.
An additional complication: Trying to do the equivalent of the +repage arg doesn't seem to have an equivalent MagickWand function. In my case, some of the input PNGs have "oFFs" sections that place the image outside of width / height box. Calling MagickCropImage warns that the image would be empty, so I need a way to discarding the offset information in the MagickWand. What should I do?
I am trying to make a program to create thumbnail images from user provided input images. I had some questions regarding how to do this. Generally speaking, I would prefer the images to be small, square images in the same file format as the input image. I am using the MagickWand API, through a Golang wrapper library.
1. What is the the difference between Properties, Profiles, Artifacts and Options? These all appear to be metadata, and there seems to be a lot of overlap in the data exposed here? Are all Profiles color profiles, or are there other kinds? Are all options set by my application, or could they be set by MagickCore when decoding the image? Is it generally safe to remove all of these? The "-strip" option to convert removes *some* of these, but not all of them.
2. I would prefer to drop color profiles, since they seem to be a few KB in size; enough to rival the image data. Is it okay to just convert all thumbnail images to the sRGB color space and depend on browsers to expect images in the sRGB color space?
3. Is it still correct to convert the input image to LAB colorspace (or another perceptually uniform colorspace) before resizing? I would like to avoid any easily avoidable degradation in image quality. From reading online it seems this is the correct way to resize, but perhaps ImageMagick does it already?
My main concern is that when I did this in my code, it didn't make any significant difference in the output thumbnail. I'm wondering if I was just noticing quantization errors due to the colorspace conversion. How do I tell if I did it right? Is there a kind of image that really shows off the difference?
4. Cropping the image down to a square has proved tricky, and I don't think I am doing it right. I am using MagickGetImagePage to get the width and height, and then cropping it down to the largest square that fits inside. The problem is that MagickCropImage doesn't seem to update the ImagePage afterwards.
An additional complication: Trying to do the equivalent of the +repage arg doesn't seem to have an equivalent MagickWand function. In my case, some of the input PNGs have "oFFs" sections that place the image outside of width / height box. Calling MagickCropImage warns that the image would be empty, so I need a way to discarding the offset information in the MagickWand. What should I do?