Padding or filling images with white instead of black?

Hi, I'd like to use the function fill or pad images (I have the Spanish version so I'm not sure how to say it English) but I'd like the images to be filled with white rather than black... is there a way around this? Thanks!

Al MB, Mac OS X (10.5.5)

Posted on Nov 4, 2008 7:34 AM

Reply
12 replies

Nov 4, 2008 8:43 AM in response to noa711

You can pad your images with any colour you like.
But you need the help of AppleScript in combination with a shell script.

Add the +Run AppleScript+ action

<pre style="
font-family: 'Courier New', Courier;
font-size: 12px;
line-height: 1;
border: 2px solid #1E90FF;
width: 600px; height: 150px;
color: #000000;
background-color: #F5FFFA;
overflow: auto;">on run {input, parameters}
repeat with this_file in input
set this_path to the quoted form of the POSIX path of this_file
do shell script "sips " & this_path & " -Z 150 -p 150 150 --padColor FFFFFF -i"
end repeat
return input
end run
</pre>

This example script will scale images to 150 pixel (for the widest side) and pad them to 150*150 with a white frame
If you don´t want to scale them use

do shell script "sips " & this_path & " -p 150 150 --padColor FFFFFF -i"

Spażek

Nov 5, 2008 2:56 PM in response to spazek

Thank you, that's almost what I wanted. I also wanted to scale images to 620 x 480 px and make automator fill the space to make the image fit into that area white; that script pads the image white but it doesn't scale it to the size I want... I tried changing the numbers but it doesn't work either. Sorry I seem stupid I've just never had any experience at all with AppleScript or any programming language for that matter...

Nov 5, 2008 4:18 PM in response to noa711

Hi noa711!

You don´t need to know about AppleScript or shell scripts to be glad with your Mac ! 🙂

Sorry, i did not understand, what you want to do. Because for me the term "scale" means, what the command "-Z" does.

So try to "scale" your images first with the needed action and then add a white frame in the next action.

But if you want the script to do all of this, here are the usefull commands. (Change the numbers/size as you like):

-Z 600

Resample image so height and width aren't greater than specified size.

-z 600 400

Resample image at specified size. Image aspect ratio may be altered.

-c 600 400

Crop image to fit specified size.

-p 600 600

Pad image with pixels to fit specified size.

-------

Spażek

Oct 6, 2011 11:28 AM in response to spazek

Spazek, thank you so much for this detailed info, I was looking everywhere on how to convert images and retain a white canvas, and I have only found it here. However, I am having an issue. I copied your Applescript into my action, and get an error in the Applescript every time I run the action.


Here is a screenshot of my action: https://files.me.com/jgelfond/giuxuq


From your script I simply modified to make image width to 190 pixels and then pad to 200x200 with a white frame.


Any idea why I would receive an Applescript error on this? Using OS 10.7.1. Thank you!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Padding or filling images with white instead of black?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.