Color correction has been restored and supports conversion between SD, HD and UHD colorimetry. Currently only 8 bit video is supported for color conversion. See post #4 for more details.
And unfortunately, another update to prevent ColorMatrix from color converting to or from UHD colorimetry. See post #6 for details.
The new CropResize should be as easy to use as the previous version (2018-03-17), at least for everyday cropping and resizing, while now covering any typical cropping/resizing scenario. It's not completely backwards compatible with the old version though, as some of the argument names have changed and new arguments have been added.
The main goal hasn't changed though......
To crop and resize without having to worry about calculating aspect error or distorting the picture.
The pictures in post #2 illustrate CropResize usage.
Some of the changes for version 2019-07-17
Anamorphic Output Support
An Output Display Aspect Ratio (OutDAR) or Output Sample Aspect Ratio (OutSAR) can now be specified.
CropResize should now be compatible with Avisynth 2.5.8, Avisynth 2.6 and Avisynth+.
Color Correction Removed - (restored with version 2019-08-10)
CropResize no longer converts the colors when upscaling or downscaling.
It previously only converted between rec.601 and rec.709, and color conversion isn't technically the job of a cropping/resizing script, so color correction has been removed entirely.
Specified cropping can now be Mod1 for any source. CropResize will increase the cropping to the correct mod when it's not resizing, or hand off any non-mod cropping to the resizer when it is.
Cropping is now split between Avisynth's Crop() function and resizer cropping more intelligently, and the cropping split can now be controlled by the CSplit argument.
Right and bottom cropping can be a positive or negative integer, applied in the same way as Avisynth's Crop() function.
Global GCropResize Function
There's a new GCropResize function for configuring the CropResize options globally when there's more than one
instance of CropResize in a script. The options can be over-ridden by individual instances of CropResize.
The GCropResize function only outputs an unmodified version of the source clip (except when global auto-cropping
is enabled). GCropResize can be used to create two sets of global variables, but as an example of usage with a
single set of global variables:
GCropResize(720,480, 8,2,-8,-4, InDAR=4.0/3.0, OutDAR=15.0/11.0)
If there's a previous global MeGUI DAR in a script, for example:
global MeGUI_darx = 4
global MeGUI_dary = 3
CropResize will automatically use it as it's Input DAR.
CropResize also creates the appropriate global MeGUI DAR variables for MeGUI to use when loading a script. MeGUI can then calculate the correct sample aspect ratio automatically and add it to the command line for encoding.
Any compatible resizer can be specified via the Resizer argument, not just Avisynth's resizers (or the Resize8 script as was the case with the previous version).
There are wrapper functions included for specifying options when resizng with the Resize8 or ResizeX scripts, the ResampleHQ plugin, and for each of the Avisynth resizers with optional arguments.
+ Reply to Thread
Results 1 to 10 of 10
Last edited by hello_hello; 16th Aug 2019 at 12:33.
The easiest way to demonstrate CropResize usage is with some pictures.
01 - The (home made) PAL 16:9 source (mpeg4 DAR) used for the following examples.
02 - Simply specify a width (or height) and let CropResize take care of the rest, resizing to "square pixel" dimensions.
CropResize(832,0, 14,2,-16,-4, InDAR=20.0/11.0, Info=true)
03 - When specifying both an output width and height, the script crops accordingly to prevent aspect error
(although specifying an OutDAR takes precedence over the cropping and output display aspect ratio).
Simply to demonstrate, here 4:3 output dimensions are specified for the 16:9 source.
CropResize(704,528, 14,2,-16,-4, InDAR=20.0/11.0, Info=true)
04 - MeGUI support.
MeGUI was used to crop the source, adding it's global DAR variables and cropping to the script.
CropResize then takes care of the resizing and any extra cropping required to prevent aspect error.
global MeGUI_darx = 368
global MeGUI_dary = 209
05 - Cropping and resizing to NTSC dimensions with a 16:9 display aspect ratio.
CropResize(720,480, 14,2,-16,-4, InDAR=20.0/11.0, OutDAR=16.0/9.0, Info=true)
06 - Cropping and resizing to NTSC dimensions, this time with an mpeg4 display aspect ratio and 8 pixel borders each side.
CropResize(720,480, 14,2,-16,-4, CropDAR=16.0/9.0, InDAR=20.0/11.0, OutDAR=20.0/11.0, Info=true)
07 - Resizing for a PAL 4:3 frame with an mpeg4 DAR, and adding borders.
Cropped extra from the sides by specifying a CropDAR of 16:10 to reduce the size of the top/bottom borders.
CropResize(704,576, 14,2,-16,-4, CropDAR=16.0/10.0, InDAR=20.0/11.0, OutDAR=4.0/3.0, Borders=true)
CropResize(720,576, InDAR=4.0/3.0, NoResize=true, Borders=true, Info=true)
08 - For the purists, there's a "Resize Width Only" mode that prevents height resizing.
It supports anamorphic input/output.
CropResize(720,0, 14,2,-16,-4, InDAR=20.0/11.0, OutDAR=16.0/9.0, ResizeWO=true, Info=true)
09 - CleanBorders is much like Avisynth's LetterBox function, only it centres the picture.
CropResize(0,0, 33,4,-16,-47, InDAR=20.0/11.0, CleanBorders=true, Info=true)
10 - FrostyBorders.
CropResize(832,468, 14,2,-16,-4, CropDAR=4.0/3.0, InDAR=20.0/11.0, Borders=true, Frosty=true)
Increasing the cropping to demonstrate the cropping previews.
The yellow lines show the cropping specified by the user.
The blue lines show any additional cropping applied by the script to prevent aspect error.
11 - Cropping preview #1.
CropResize(960,540, 35,4,-16,-5, InSAR=16.0/11.0, CPreview=1)
12 - Cropping preview #2 with Info=true.
CropResize(960,540, 35,4,-16,-5, InSAR=16.0/11.0, CPreview=2, Info=true)
13 - Cropping preview #3.
CropResize(720,576, 35,4,-16,-5, InSAR=16.0/11.0, OutDAR=16.0/9.0, CPreview=3)
Last edited by hello_hello; 13th Aug 2019 at 06:41. Reason: Forgot to update some of the CropResize arguments when updating the screenshots
There's a new version of CropResize (2019-08-08). The link in the opening post has been updated.
The changes are aimed at making the script's behaviour more predictable, although there's not a lot of them. The cropping and resizing functionality remains the same. There's a list of changes in the zip file.
Another update. I've added back automatic color conversion when upscaling/downsaling between SD, HD and UHD. It's disabled by default, but it can be enabled by default so there's no need to use the ColorCorrect argument. Details in the help file.
ColorCorrect=0 is disabled, ColorCorrect=1 converts with the ColorMatrix plugin, and ColorCorrect=2 converts with DitherTools. Currently only 8 bit video is supported for color conversion.
I don't think there's a 64 bit version of ColorMatrix with Rec.2020 support, but the included 32 bit version has it. It supports YV12 & YUY2.
DitherTools supports Rec.2020 and YV12, YV16, YV24, YV411, and Y8.
The new version is dated 2019-08-10. The link in the opening post has been updated.
I was hoping I'd uploaded the last version, aside from maybe updating the color correction to support all native Avisyth+ bitdepths, but a bug managed to slip past the keeper.
Fixed an incorrect output display aspect ratio calculation when NoResize=true and an input sample aspect ratio was specified. The script was still cropping correctly, but the output display aspect ratio calculation was wrong.
New version in the opening post dated 2019-08-12.
Unfortunately I've had to upload a new version of CropResize sooner than I'd planned. The new version in the opening post is dated 2019-08-17.
While doing some testing for (hopefully) the upcoming version with the ColorCorrect option supporting Avisynth+ native bitdepths (greater than 8 bit), I discovered the version of ColorMatrix that was included in the zip file doesn't convert UHD colorimetry correctly (Rec.2020). As a result, the new version of the script will output an error if ColorCorrect=1, the source or destination resolution is UHD, and the script needs to color correct due to upscaling or downscaling. If you have DitherTools, ColorCorrect=2 can be used instead.
For the record, ColorMatrix seemed to be getting "Rec.709->Rec.2020" conversions right, but no other conversions involving Rec.2020 are correct (they don't match HDRTools & DitherTools).
ColorMatrix is still fine for conversions between HD and SD colorimetry. The standsrd version without Rec.2020 support has been around for years.
Last edited by hello_hello; 16th Aug 2019 at 18:28.
Hey, nice script you got there, do you mind to help me out with some questions.
This is the source that I'm using with your script:
This is the script:
ImageSource("ssf-source.png") CropResize(0,480, 0,0,0,0, InDAR=12.0/7.0, Info=true)
It tries to resize keeping the AR 12:7 but if I try to force a resize it to a 4:3 resolution like 640x480, the result still looks stretched horizontally and cropped:
CropResize(640,480, 0,0,0,0, InDAR=12.0/7.0, OutDAR=4.0/3.0, Info=true)
I'm looking to get something like this:
What do I have to do to make your script to resize like that with the correct proportions?
Now I use a spreadsheet to calculate the Horizontal or Vertical resolution manually + jagabo's script, your script it's all in one solution, very handy. Arcade resolutions are a pain in the butt, specially CAPCOM's, this guy cover this matter in great detail.
Got the script working:
To make it work I set InDAR with desired DAR 4:3 instead of SAR 12:7.
CropResize(0,480, 0,0,0,0, InDAR=4.0/3.0, Info=true)
There is an input sample aspect ratio option. It's InSAR, as opposed to InDAR, so you can specify either, but....
So you know, the video you linked to possibly makes it sound more complicated than it is. Each game has to display as 4:3, no matter what the storage aspect ratio (resolution), and the game in your screenshot has a resolution of 384x242. To determine the (input) sample/pixel aspect ratio:
storage height × display aspect ratio = display width
display width / storage width = sample aspect ratio
Doing it in a single equation: 224 × (4 / 3) / 384 = 0.777778 or (7:9)
So InSAR=7.0/9.0 is the same as InDAR=4.0/3.0 for that one. If the resolution changes the sample/pixel aspect ratio probably will too, so it'd be simplest to use InDAR=4.0/3.0 all the time and let the script do the math.
The 12:7 aspect ratio he refers to is the resolution (storage aspect ratio), although it'd be easy to think he was referring to a sample/pixel aspect ratio. I did at first.
By the way... keep an eye out for the new version of CropResize with additional color conversion options. It'll also convert with HDTools and AVSResize. Both support all the native AVisynth+ bitdepths, as far as I know. I just need to install Win7 on something so I can check the AVSResize part as it won't run on XP. Hopefully it'll be ready to go some time next week.
Last edited by hello_hello; 23rd Aug 2019 at 03:09.
I'll look forward to it.
Last edited by amaipaipai; 23rd Aug 2019 at 04:19.