Page 1 of 1
resize + alpha script
Posted: 2010-01-13T08:35:49-07:00
by aikiko
Hello,
I am trying to write a script to resize wallpapers I have. The monitor is 1680*1080 but there is on the top 2x24 pixels used for the menu and 24 pixels at the bottom for the taskbar. So would like to create a script to
resize the images to 1600*978 with keeping the h x v ratio if they are bigger the this value
convert img -resize 1680x978\> img2
place the img2 on an alpha layer of 1600*978 but the problem is that i do not know the size so the draw fonction does not seem possible ...
thx
Aikiko
Re: resize + alpha script
Posted: 2010-01-13T08:54:35-07:00
by fmw42
what do you mean by place the image on an alpha layer? where does -draw come in to the process?
can you give a full command line and/or explain your actual goal for the layout of the output image and its layer.
should it not be:
convert img -resize "1600*978\>" -gravity center -background black -extent 1600x978 img2
so that it fills out the shorter size to fill your required size.
I am puzzled where you get 1600x978?
You start with 1680*1080 then subtract (not sure if it is 48 or 72 in height from your explanation) so it should be either 1680x1032 or 1680x1008?
Re: resize + alpha script
Posted: 2010-01-13T11:15:23-07:00
by aikiko
1600*978 = 1600*1050 - 24x2 (top menu) - 24x1(taskbar)
The monitor is 1050 and not 1080 sorry ...
Code: Select all
convert img.jpg -resize 1600x978\> -gravity center -background transparent -extent 1600x978 img2
This thing works but the border is black instead of transparent so i had the convert the images to png so it can handle transparency, but with png it works great
I tried to find out but is the a way to make an asymetric border ? 48pixel on the top and 24 on the bottom ? Or add 48 pixels at the top and 24 on the bottom ... or any other ways ?
Re: resize + alpha script
Posted: 2010-01-13T11:37:03-07:00
by fmw42
Re: resize + alpha script
Posted: 2010-01-13T14:35:51-07:00
by aikiko
It works.
Code: Select all
#!/bin/bash
#for img in `ls *.png`
for img in `ls *.png`
do
convert "$img" -resize 1600x978\> -gravity center -background transparent -extent 1600x978 temp
convert temp -gravity South -background transparent -splice 0x24 temp
convert temp -gravity North -background transparent -splice 0x48 resized_$img
rm temp
done
Thanks for the help
Re: resize + alpha script
Posted: 2010-01-13T15:11:31-07:00
by fmw42
convert "$img" -resize 1600x978\> -gravity center -background transparent -extent 1600x978 temp
convert temp -gravity South -background transparent -splice 0x24 temp
convert temp -gravity North -background transparent -splice 0x48 resized_$img
rm temp
You should be able to do this all in one command without a temp
convert "$img" -resize 1600x978\> -gravity center -background transparent -extent 1600x978 \
-gravity South -splice 0x24 \
-gravity North -splice 0x48 resized_$img