Use color picker to set background color?

Post Reply
User avatar
magnussandstrom
Advanced member
Posts: 447
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Use color picker to set background color?

Post by magnussandstrom »

I have a flow that creates PDF from images and scale to a certain page size. But sometimes the proportions (aspect ratio) doesn't match the final size, which means that I get white stripes on the vertical or horisontal sides. But I would like fill the white background with a solid color that I pick from a certain part of the image (image edge).

Do you know of any way to achieve this?

Example:
color_picker.jpg
color_picker.jpg (241.57 KiB) Viewed 4732 times
User avatar
JimmyHartington
Advanced member
Posts: 365
Joined: Tue Mar 22, 2011 7:38 am

Re: Use color picker to set background color?

Post by JimmyHartington »

May I present another solution.
Do like when TV shows vertical video on a 16:9 TV.

Image

This action list scales the pdf to A4. https://d.pr/f/lMRKEb+
Copies the image to the background.
Scales the image non-proportinally to fit A4.
Blurs the image.
User avatar
magnussandstrom
Advanced member
Posts: 447
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Use color picker to set background color?

Post by magnussandstrom »

Thanks Jimmy, this is great! I will suggest this solution instead.
freddyp
Advanced member
Posts: 1078
Joined: Thu Feb 09, 2012 3:53 pm

Re: Use color picker to set background color?

Post by freddyp »

You can pick a color value from a pixel with Imagemagick:

Code: Select all

magick image.png -format "%[fx:int(255*p{150,30}.r)],%[fx:int(255*p{150,30}.g)],%[fx:int(255*p{150,30}.b)]" info:
This will give you an output like:
139,165,224

p{150,30} is the pixel of which you read the value. The problem that I see is how to determine which pixel to take, or could you settle on a fixed location?

With Imagemagick you can also replace pixels of one color with pixels of another color. So it looks to me as if you can make it work this way should you decide not to follow Jimmy's suggestion which, by the way, I think is a good approach: it invalidates the need for choosing the correct pixel from which to take a color value.
Post Reply