View Full Version : Resize doubt.
super_dubukku
30th October 2007, 11:50
Iam making a slide show with images of different sizes. Finally all of them needs to be converted to 320x240 size. But I want the aspect ratio to be preserved. For eg., there are two images Image1 300x240 & Image2 320x200.
I want them to be resized to 320x240 with aspect ratio preserved. Meaning, for the Image1, black band should apppear at the left and right side. And for the Image2 black band should appear at the top & bottom. Both of them should be sized to 320x240.
Can any one help me with the AVISynth script to do that ?
Thanks,
Guest
30th October 2007, 13:45
For the 300x240 image:
AddBorders(10,0,10,0)
For the 320x200 image:
AddBorders(0,20,0,20)
super_dubukku
31st October 2007, 08:07
Thanks a lot. AddBorders solved the problem.
I have one more question too. To do resizing currently I use Irfanview Batch Conversion with preserve aspect ratio option. Resize size being set to 320x240. Here is an example.
Original image Resized Image
475x480 237x240
800x323 320x129
595x555 257x240
Can this be achieved with AVISynth's ReSize filters or Donald Graft's SmartResize filter or with VirtualDub's resize filter ?
(Iam not sure if VirtualDub's built-in filters can be used from AVIsynth scripts)
Thanks,
IanB
31st October 2007, 10:52
Can this be achieved with AVISynth's ReSize filters or Donald Graft's SmartResize filter or with VirtualDub's resize filter ?
(Iam not sure if VirtualDub's built-in filters can be used from AVIsynth scripts)Yes. Yes. Yes, but you cannot use internal VDub filters in Avisynth (unless some kind soul cuts out the code and builds a free standing version).
RGB formats have no restrictions. YUY2 format must have width divisible by 2. YV12 format must have both width and height divisible by 2, and the final output size must be divisible by 4.
super_dubukku
31st October 2007, 16:54
Thatz great. Very excited.
Please give me an example script code. From the AVISynth documentation I could not understand how to achieve that. Sorry for being dumb.
foxyshadis
31st October 2007, 20:30
Based on something I use for my own images:
function shrinkerxy(clip c, int "maxx", int "maxy") {
maxx=default(maxx,320) * 1.0
maxy=default(maxy,240) * 1.0
c
mod = isrgb ? 1 : 2
wider = width/height*1. > maxx/maxy
neww=wider? maxx.int : m(mod,maxy/height*width)
newh=wider? m(mod,maxx/width*height) : maxy.int
Spline36Resize(neww,newh)
c.width > maxx || c.height > maxy? last : c
}
function m(int r, float x) {return(x<16?16:int(round(x/float(r))*r))}
You can extend that to use addborders to fill it out, but I don't bother.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.