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:
Use color picker to set background color?
- magnussandstrom
- Advanced member
- Posts: 420
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
- JimmyHartington
- Advanced member
- Posts: 350
- Joined: Tue Mar 22, 2011 7:38 am
Re: Use color picker to set background color?
May I present another solution.
Do like when TV shows vertical video on a 16:9 TV.
![Image](https://d.pr/i/ImXIhE+)
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.
Do like when TV shows vertical video on a 16:9 TV.
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.
- magnussandstrom
- Advanced member
- Posts: 420
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: Use color picker to set background color?
Thanks Jimmy, this is great! I will suggest this solution instead.
Re: Use color picker to set background color?
You can pick a color value from a pixel with Imagemagick:
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.
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:
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.