Thêm logo hàng loạt¶
Thu nhỏ logo theo tỉ lệ 10% so với ảnh nền và ở vị trí góc phải trên cùng cách mép ảnh 3% chiều dài ảnh nền
gci -recurse -file | Foreach-Object {
magick $_.fullname ..\logo.png -resize %[fx:t?u.w*0.1:u.w]x%[fx:t?u.h*0.1:u.h] -gravity northeast -geometry +%[fx:t?u.w*0.03:u.w]+%[fx:t?u.w*0.03:u.w] -composite new"$_.name"
}
Script: Adding multiple logos to multiple images.ps1
The reasoning behind the %[fx:t?u.w*0.9:u.w]
¶
From The FX Special Effects Image Operator:
u: first image in list
v: second image in list
t: index of current image (s) in list
w: width of this image
So in plain language, it means that if the image in question is the second image, whose index is one, of which the ternary conditional operator also read as true, then resize it to 90% width of the first image, else do no resize. Or else -resize
option will apply to each images in an image sequence (i.e. all input images before it, but not after it).
Resize and crop¶
I have over 1000 images on different resolutions, (for example 1234x2122, 4400x5212 , etc) and I want to convert all of them to fixed 100x100 size, so.
-
first I need to resize the images keeping proportions, and get 100xA or Ax100, where A > 100 (it depends width and height of image, for some images width > height, and for some images height > width).
-
Crop this image to 100x100 from center
You would use the area-fill (^
) geometry modifier on the-resize
operation to unify the down-scale. For cropping the center,-extent
with-gravity Center
will work.
Tạo : 1 tháng 5, 2023