2

Some website requires the user to "crop" the photo, but sometimes you'd like to keep it original.

Using OS X alone, can a a 500 x 640 photo be enlarged to 640 x 640 (with white or black bars at the left and right), without installing additional apps? (this can be viewed as, creating a 640 x 640 black image, and the pasting the 500 x 640 photo onto it).

  • 2
    Open it in Preview and take a screenshot? – nohillside Apr 28 '16 at 7:11
  • that might work (you can set the background color in Preview). Except then you have to crop out the image region and make sure it is exactly 640 x 640? also it seems a little bit hacky – nopole Apr 28 '16 at 7:19
10

You can use the sips command to pad any JPEG or BMP image to a specified size, with a specified colour. In your case, the command would look something like:

sips photo-500x640.jpg --padToHeightWidth 640 640 --padColor 000000 --out photo-640x640.jpg

obviously with the input and output filenames of your choice. For white instead of black borders, change 000000 to FFFFFF.

  • it works perfect – nopole Apr 28 '16 at 14:41
  • 1
    Just curious: can you configure a transparent --padColor? – Nzall Apr 28 '16 at 15:01
  • Don't think there's a way to specify that, but it used to be that if you tried to pad a PNG, it would pad with transparency regardless of the colour you specified. Haven't tried recently to see if that's still the case. – calum_b Apr 29 '16 at 9:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .