Hi everyone,
I have been trying to figure out a script that will allow me to autoresize an image using AviSynth.
The objective is to create menus or slideshows for DVD's. This is what I have so far... but doesn't work!
ImageSource(file="C:\********.jpg") #Reads my image
ow=last.width #gets image original width
oh=last.height #gets image original height
nw=int(round(452/oh)*ow) #computes new width, based on a height of 452
LanczosResize(nw,452)
Example: The image originally is 455x600. The new size should be, (452/600)*455) = 343 pixels width. So output should be an image 343x452. But I get error message: Resize: Width must be bigger than or equal to 8.
Help !
+ Reply to Thread
Results 1 to 9 of 9
-
-
Yup, for video, your dimensions must be multiples of 8, preferably 16
-
shudnt the size be dividable by 8 or 16?
EDIT: Posted at the same time :P -
I believe the frame dimensions are integers so multiply before dividing. From your code:
nw = int(round(452/oh)*ow) = int(round(452/600)*455) = int(round(0)*455) = 0
Try on of these:
nw=452*ow/oh #may not work for YUY2 or YV12
nw=(452*ow/oh+2)/4*4 #for nearest mod 4 frame size
nw=(452*ow/oh+4)/8*8 #for nearest mod 8 frame size
nw=(452*ow/oh+8)/16*16 #for nearest mod 16 frame size -
Originally Posted by jagabo
The first line works for me. Now I just fave to figure how to create a autoBorder using AddBorders. The output should be a 720x480, which the height will be given but for the width I have to use IF conditions. Then whatever value I would get has to be divided by 2, for equal distribution. Something that I need to learn.
-
I suspected the question of border sizes would come up next!
Without accounting for aspect ratio corrections:
lb = (704-nw)/2 #size of left border
rb = 704-nw-lb #size of right border
addborders(lb, 14, rb, 14)
But if you're making a DVD you need to correct for the aspect ratio. Aspect ratio has to be taken into account in the resizing too. I'll have to think about it a bit... -
Hi Jagabo!
If is not too much already, would you please help me with Aspect Ratios (AR). I'm using DVDLab Pro 1.?? I know that DVDLab takes cares of ARs but the reason for finding a script was to polish the picture. That is, denoising and sharping it and trying to give them a homogeneous size.
Thanks for the prior code... -
OK, I'm not real familiar with AVISynth syntax but I've come up with this:
Code:function PadHeight(clip image, int width, int height, int AR_WIDTH, int AR_HEIGHT) { # the frame is wider than we want, pad the top and bottom # calculate what final height we need nh = width * AR_HEIGHT / AR_WIDTH # calculate the top and bottom borders tb = (nh - height) / 2 bb = nh - height - tb AddBorders(image, 0, tb, 0, bb) } function PadWidth(clip image, int width, int height, int AR_WIDTH, int AR_HEIGHT) { # the frame is taller than we want, pad the left and right # calculate the final width we need nw = height * AR_WIDTH / AR_HEIGHT # calculate the left and right borders lb = (nw - width) / 2 rb = nw - width - lb AddBorders(image, lb, 0, rb, 0) } ImageSource("E:\VCR\AVS\AutoResize.jpg") # if you want 16:9 change these values to 16 and 9 AR_WIDTH = 4 AR_HEIGHT = 3 width = last.width height = last.height ((width * AR_HEIGHT) > (height * AR_WIDTH)) \ ? PadHeight(last, width, height, AR_WIDTH, AR_HEIGHT)\ : PadWidth(last, width, height, AR_WIDTH, AR_HEIGHT) # the frame is now padded to the correct square pixel aspect ratio # resize for DVD LanczosResize(704, 480) AddBorders(8, 0, 8, 0) #optional
LanczosResize(664, 452)
AddBorders(28, 14, 28, 14)
Or even better (everything mod 16):
LanczosResize(656, 448)
AddBorders(32, 16, 32, 16)
Note that the above script won't work for certain frame sizes in YUY2 and YV12.
Similar Threads
-
Avisynth - How to resize a 720p video, internally 1024x760??
By Cauptain in forum EditingReplies: 13Last Post: 8th Apr 2012, 10:59 -
Trying to keep original resolution, but programs seem to auto crop/resize
By nyder in forum DVD RippingReplies: 3Last Post: 14th Aug 2011, 03:34 -
Avisynth Aspect Ratio Resize Help
By t4com4 in forum Newbie / General discussionsReplies: 9Last Post: 1st Oct 2010, 10:30 -
tmpgenc xpress auto resize results in 708 width in 720 frame.
By davexnet in forum Video ConversionReplies: 0Last Post: 27th Jan 2010, 13:49 -
Which one directshow filter to resize the image ?
By jazzzy in forum Software PlayingReplies: 1Last Post: 20th Feb 2008, 09:55