Sips shows Cannot display target image

I used sips to resize the PNG image as shown below.

sips -z 768 1024 image.png --out image-resize.png

It works well. But today I received an error message as shown below.

<CGColor 0x7ffb72e05c40> [<CGColorSpace 0x7ffb72e04e70> (kCGColorSpaceDeviceRGB)] ( 0 0 0 1 )
Error: Unable to render destination image

If anyone can help, it will be very appreciated.

+4
source share
2 answers

Changing the color profile value from 16-bit RGB to 8-bit sRGB resolves this issue.

This can be done with a single command in the terminal:

find . -type f -name '*.png' -print0 | while IFS= read -r -d '' file; do sips --matchTo '/System/Library/ColorSync/Profiles/sRGB Profile.icc' "$file" --out "$file"; done

Images can then be resized. For batch resizing, I use this command:

mdfind -0 -onlyin . "kMDItemPixelHeight > 600 || kMDItemPixelWidth > 600" | xargs -0 sips -Z 600

And upon completion, this command reduces the size of the image files:

find . -name '*.png' -exec pngquant --skip-if-larger --ext .png --force {} \; -exec xattr -c {} \;
+1
source
sips -s format jpeg image.png --out image.jpg
sips -z 768 1024 image.jpg --out image-resize.jpg
+1

Source: https://habr.com/ru/post/1659248/


All Articles