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
resize + alpha script
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: resize + alpha script
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?
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
1600*978 = 1600*1050 - 24x2 (top menu) - 24x1(taskbar)
The monitor is 1050 and not 1080 sorry ...
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 ?
The monitor is 1050 and not 1080 sorry ...
Code: Select all
convert img.jpg -resize 1600x978\> -gravity center -background transparent -extent 1600x978 img2
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 ?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: resize + alpha script
jpg does not support transparency, use png or gif
see http://www.imagemagick.org/Usage/crop/#border and http://www.imagemagick.org/Usage/crop/#splice
see http://www.imagemagick.org/Usage/crop/#border and http://www.imagemagick.org/Usage/crop/#splice
Re: resize + alpha script
It works.
Thanks for the help
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: resize + alpha script
You should be able to do this all in one command without a tempconvert "$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
convert "$img" -resize 1600x978\> -gravity center -background transparent -extent 1600x978 \
-gravity South -splice 0x24 \
-gravity North -splice 0x48 resized_$img