7

I had used sips to resize PNG image as below command.

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

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

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

If anyone could help it would be very much appreciated.

Daniel Lu
  • 189
  • 1
  • 14

2 Answers2

7

Changing color profile value from RGB 16bit to 8bit sRGB fixing this problem.

This can be done by one command in 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

Then images can be resized by sips. For batch resize I use this command:

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

And at finish, this command for reduce size of image files:

find . -name '*.png' -exec pngquant --skip-if-larger --ext .png --force {} \; -exec xattr -c {} \;
Igor
  • 12,165
  • 4
  • 57
  • 73
-1
sips -s format jpeg image.png --out image.jpg
sips -z 768 1024 image.jpg --out image-resize.jpg
Pang
  • 9,564
  • 146
  • 81
  • 122
name-1001
  • 120
  • 2
  • 4
  • 1
    **From review queue:** May I request you to please add some more context around your answer. Code-only answers are difficult to understand. It will help the asker and future readers both if you can add more information in your post. – help-info.de May 19 '17 at 17:35