Is there any command which will split image as described in example like XnViewMp Create>SplitImage
For example 3x7 px file
nconvert -split 2 3 -output out_#w_#h.png in.png
it will generate 6 image like
out_000_000.png (2x3)
out_000_001.png (2x3)
out_000_002.png (2x1)
out_001_000.png (1x3)
out_001_001.png (1x3)
out_001_002.png (1x1)
NConvert split images to required width & height using coordinates
Moderators: XnTriq, helmut, xnview
-
- Posts: 5
- Joined: Fri Nov 24, 2023 11:25 am
-
- XnThusiast
- Posts: 4172
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: NConvert split images to width & height with coordinates
Have you looked at the NConvert help file?
I think that the following option might be used to do what you want, although if you actually want to create outputs with very small pixel dimensions like 2x3 I am not certain whether that will work although in principle it probably should:
You would, of course, probably need to use a batch file running code once for each required output.
I think that the following option might be used to do what you want, although if you actually want to create outputs with very small pixel dimensions like 2x3 I am not certain whether that will work although in principle it probably should:
Code: Select all
-crop x y w h : Crop
-
- Posts: 5
- Joined: Fri Nov 24, 2023 11:25 am
Re: NConvert split images to width & height with coordinates
I examine it, but crop can only generate one image, but what I am searching is it will generate all files because of if we try to geneate files in for loop executeCommand, it will read original file in everytime and will be very slow for big files.
-
- XnThusiast
- Posts: 4172
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: NConvert split images to width & height with coordinates
Understood, XnView MP has in the file browser a function Create > Split image(s)... which is something like what you are looking for although not exactly the same.
I haven't checked the help file for the current NConvert download, and doubt if an equivalent option has been added, but Pierre has in the past been quite responsive to requests for new options to be ported to NConvert. If you haven't already done so, you might at least check the help file for anything I have missed.
I'm also assuming that NConvert can only output the result of one crop when it is run, but the detailed operation other than the available switches is in general not documented.
Otherwise, depending on your exact need, you might at least be able to optimise a script to minimise the run time, taking into account the fact that as a source image is divided the resulting smaller images will load more quickly. Or maybe you could run multiple instances of NConvert, each outputting a proportion of the required outputs??
I haven't checked the help file for the current NConvert download, and doubt if an equivalent option has been added, but Pierre has in the past been quite responsive to requests for new options to be ported to NConvert. If you haven't already done so, you might at least check the help file for anything I have missed.
I'm also assuming that NConvert can only output the result of one crop when it is run, but the detailed operation other than the available switches is in general not documented.
Otherwise, depending on your exact need, you might at least be able to optimise a script to minimise the run time, taking into account the fact that as a source image is divided the resulting smaller images will load more quickly. Or maybe you could run multiple instances of NConvert, each outputting a proportion of the required outputs??
-
- Posts: 5
- Joined: Fri Nov 24, 2023 11:25 am
Re: NConvert split images to required width & height using coordinates
I examine all but I can't find like what I want.
Latest (in website described as 'Version 7.163' but when download for linux) nconvert -help output:
Latest (in website described as 'Version 7.163' but when download for linux) nconvert -help output:
Code: Select all
** NCONVERT [b]v7.155[/b] (c) 1991-2023 Pierre-E Gougelet (Sep 8 2023/13:54:44) **
Version for Linux x86 (X11) (All rights reserved)
** This is freeware software (for non-commercial use)
The JPEG code is based in part on the work of the Independent JPEG Group's software.
The PNG code is based in part on the work of the Group 42, Inc.
This software is based in part on compression library of Jean-loup Gailly and Mark Adler
Usage : nconvert [options] file ...
Options :
-quiet : Quiet mode
-info : Display informations only
-fullinfo : Display informations & metadata only
-v[.] : Verbose
-in format : Input format number or -1
-page num : Page/image number
-xall : Extract all images
-multi : Create a multi-page (TIFF/DCX/LDF/PDF only)
-npcd num : PCD 0:192x128, 1:384x256, 2:768x512 (default)
-ngrb npic : HP-48 number of grey : 1, 2 or 4 (default : 1)
-no# : # not used for numeric operator
-noholder : disable placeholder such as $%
-org_depth : Load with original depth
-older n : Convert only if older than n days
-greater_than type value : Process only if arg is greater than value: Overwrite existing file
-less_than type value : Process only if arg is less than value
type : height(px) width(px) filesize(bytes)
-overwrite : Overwrite existing file
-ignore_errors : Ignore errors
-no_auto_ext : Don't add extension to output filename
-ctype type : Channel Type (Raw)
grey : Greyscale (default)
rgb : Red,Green,Blue
bgr : Blue,Green,Red
rgba : Red,Green,Blue,Alpha
abgr : Alpha,Blue,Green,Red
cmy : Cyan,Magenta,Yellow
cmyk : Cyan,Magenta,Yellow,Black
-corder order : Channel Order (Raw)
inter : Interleaved (default)
seq : Sequential
sep : Separate
-size geometry : Width and height (Raw/YUV)
Geometry is widthxheight+offset
-l file : Use file as filelist
-n start end step : Begin End Step (for image sequence)
-t start step : Begin Step (for # in output filename)
-o filename : Output filename
Use # to specify position of numeric enumerator
Use % to specify source filename
Use $ to specify full source pathname
Use $$ to specify source folder name
Use $EXIF:DateModified[date format] to specify EXIF date modified
Use $EXIF:DateTaken[date format] to specify EXIF date taken
Date format: Please check documentation of strftime
-out format : Output format name
-D : Delete original picture
-c value : Compression number
default : 0 (uncompressed)
PDF : 1 (Fax), 2 (Rle), 3 (LZW), 4(ZIP), 5 (JPEG)
TIFF : 1 (Rle), 2 (LZW), 3 (LZW+Prediction)
4 (ZLIB)
5 (CCITT G3), 6 (CCITT G3-2D), 7 (CCITT G4) only B/W
8 (JPEG) only 24/32 bits
TARGA, Softimage, SGI, PCX, IFF, BMP : 1 (Rle)
-c_bw value : Compression number for black&white picture (default : 0)
-c_grey value : Compression number for greyscale picture (default : 0)
-c_rgb value : Compression number for color picture (default : 0)
-q value : JPEG/FPX/WIC/PDF/JPEG2K/WebP quality (default : 85)
-use_org_quality : JPEG when possible
-clevel value : PNG Compression level (default : 6)
-i : Interlaced GIF / Progressive JPEG
-icc : Use ICC Profile
-keep_icc : Keep ICC Profile from original file
-icc_in filename : Input color profile
-icc_out filename : Output color profile
-icc_intent value : Intent value
-icc_bcp : Black point compensation
-icc_ie : Ignore embedded ICC profile
-add_alpha value : Add alpha channel (24bits)
-merge_alpha : Merge alpha by using 'transparent color' (32bits)
-set_alpha : Add alpha by using 'transparent color' (32bits)
-transparent value: Transparency index (GIF/PNG)
-transpcolor red green blue: Transparency color (GIF/PNG)
-opthuff : Optimize Huffman Table (JPEG)
-dct value : DCT method
0 : Slow
1 : Fast
2 : Float
-smoothingf value : Smoothing factor (0-10)
-subsampling value : Subsampling factor
0 : 2x2,1x1,1x1
1 : 2x1,1x1,1x1
2 : 1x1,1x1,1x1
-comp_ratio value: Compress ratio (JPEG2K)
-max_filesize value: Maximum filesize kb (JPEG2K)
-bgcolor red green blue: Background color (for rotate/canvas)
-bgcolor2 red green blue alpha: Background color (for rotate/canvas)
-dpi res_dpi : Set the resolution in DPI
-keepdocsize : Resize bitmap function of the old and new DPI value
-keepfiledate : Keep original file data/time
-keepcspace : Keep original color space if possible
-cmyk_space : Convert if possible in CMYK space
-jpegtrans op : JPEG lossless transformations
rot90 : Rotate 90 degrees
rot180 : Rotate 180 degrees
rot270 : Rotate 270 degrees
exif : Use orientation EXIF tag
vflip : Flip vertical
hflip : Flip horizontal
-jpegcrop x y w h : JPEG lossless crop
-clean value : JPEG Clean Metadata (EXIF/IPTC/...)
1 : Comment
2 : EXIF
4 : XMP
8 : EXIF thumbnail
16 : IPTC
32 : ICC Profile
64 : Other markers
-rmeta : Remove Metadata (EXIF/IPTC/...)
-rexifthumb : Remove EXIF thumbnail
-buildexifthumb : Try to rebuild EXIF thumbnail
-exif_orient value : Set EXIF orientation value
1 = Horizontal
2 = Mirror horizontal
3 = Rotate 180
4 = Mirror vertical
5 = Mirror horizontal and rotate 270 CW
6 = Rotate 90 CW
7 = Mirror horizontal and rotate 90 CW
8 = Rotate 270 CW
-iptc_print tag : Print IPTC tag value
-iptc_clear tag : Erase IPTC tag
-iptc_set tag value : Set value to IPTC tag
-iptc_add tag value : Add value to IPTC tag
-thumb width height : Extract thumbnail
-use_cie : Use CIE Colors (PS/EPS/PDF ghostscript)
-wflag flag : Write flag
os2 : Write OS/2 bmp
gif87 : Write GIF87a
hp49 : Write HP49
-half_res : Load half resolution (Camera RAW)
-embedded_jpeg : Load embedded jpeg (Camera RAW)
-ascii : Ascii (PPM)
-one_strip : One strip (TIFF)
-jxr_color value : JpegXR color format (yuv444, yuv422, yuv420)
-jxr_filter value : JpegXR block filtering
0: off, 1: HP, 2:all
-avif_format value : AVIF format (0:444, 1:422, 2:420)
-avif_speed value : AVIF speed (0-10)
-avif_quant_color lossless min max : AVIF Quantization for color (lossless=0/1, min-max=0/63)
-avif_quant_alpha lossless min max : AVIF Quantization for alpha (lossless=0/1, min-max=0/63)
-gam value : Gamma (EXR, HDRI), default=1.0
-raw_autobalance : Auto balance (Camera RAW)
-raw_camerabalance : Camera balance (Camera RAW)
-raw_autobright : Auto brightness (Camera RAW)
-raw_gamma value : Gamma (Camera RAW), default=0.6
-raw_brightness value : Brighness (Camera RAW), default=0.8
-raw_redscale value : Red scaling (Camera RAW)
-raw_bluescale value : Blue scaling (Camera RAW)
-ilut file : Input LUT file (DPX/Cineon)
-olut file : Output LUT file (DPX/Cineon)
-wmfile file : Watermark file (Must be after other -wm commands)
-wmpos x y : Watermark position
-wmflag flag : Watermark position
top-left, top-center, top-right
center-left, center, center-right
bottom-left, bottom-center, bottom-right
-wmopacity value : Watermark opacity (0-100)
-wmstretch : Stretch image
-wmsize value : Percent for watermark
Process :
-32bits : Convert in 32bits
-average size : Average (3,5,7,9,11,13)
-autocrop tol r g b : Auto Crop
-autocrop tol pos : Auto Crop
top-left, top-right
bottom-left, bottom-right
-autocontrast : Auto Contrast
-autodeskew r g b : Auto Deskew
-autolevels : Auto Levels
-balance r g b : Color balance
-binary dither : Convert in Binary
pattern : Ordered pattern
floyd : Floyd-Steinberg
halft45 : Halftone 45
halft90 : Halftone 90
nodither : No dithering
-blur percent : Blur (1...100)
-brightness value : Modify brightness (-100...100)
-canvas w h pos : Resize canvas
w h can be percent (ex: -canvas 100% 200%)
w h can be cm (ex: -canvas 100cm 200cm)
w h can be mm (ex: -canvas 100mm 200mm)
w h can be inches (ex: -canvas 100i 200i)
or #x #y for offset
pos top-left, top-center, top-right
center-left, center, center-right
bottom-left, bottom-center, bottom-right
-canvas longest size pos : Scale longest side
-canvas shortest size pos : Scale shortest side
-conbright value : Modify brightness (-100...100)
-colours num
-colors num : Convert in Indexed Colors (256, 216, 128, 64, 32, 16 or 8)
-compare filename method : Compare with this image, method (red, red_only)
-contrast value : Modify contrast (-100...100)
-crop x y w h : Crop
-dither : Use Bayer dithering for conversion (Colors and Grey only)
-deinter k n : De-interlace
k : even or odd
n : dup or int
-edetail : Enhance detail
-eedge percent : Enhance edges (1...100)
-edgedetect type : Edge detect
light/medium/heavy
-efocus : Enhance focus
-emboss : Emboss
-embossmore : Emboss more
-equalize : Equalize
-exposure value : Exposure
-floyd : Use floydSteinberg dithering for conversion (Colors and Grey only)
-frestore : Focus restoration
-gamma value : Modify gamma (0.01<->5.0
-gammasat value : Modify gamma (0.01<->5.0
-gauss size : Blur gaussian (3,5,7,9,11,13)
-grey num : Convert in Greyscale (256, 128, 64, 32, 16, 8 or 4)
-colorize h l s : Colorize Hue Lightness Saturation
-hls h l s : Adjust Hue Lightness Saturation
-lens percent : Lens (1...100)
-levels b w : Levels
-levels2 in_low in_high gamma out_low out_high : Levels
-log : Apply logarithmic correction
-maximum size : Maximum filter (3,5,7,9,11,13)
-medianb size : Median Box filter (3,5,7,9,11,13)
-medianc size : Median Cross filter (3,5,7,9,11,13)
-minimum size : Minimum filter (3,5,7,9,11,13)
-mosaic size : Mosaic (1...64)
-negate : Negate
-new bpp w h : Create new bitmap
-noise reduce : Reduce noise
-noise type value
uniform : Add uniform noise
gaussian : Add gaussian noise
laplacian : Add laplacian noise
poisson : Add poisson noise
-normalize : Normalize
-oil size : Oilify (1...16)
-posterize count : Posterize (2...256)
-ratio : Keep the aspect ratio for scaling
-replace r g b r g b : Replace color
-replace_ex r g b r g b tolerance : Replace color
-rtype : Type of resampling
quick : Quick resize
linear : Bi-linear (linear)
hermite : Hermite
gaussian : Gaussian
bell : Bell
bspline : Bspline
mitchell : Mitchell
hanning : Hanning
lanczos : Lanczos
lanczos2 : Lanczos2
-rflag : Flag for resizing
incr : Increase only
decr : Decrease only
orient : Follow orientation
-resize w h : Scale width-height
w h can be percent (ex: -resize 100% 200%)
w h can be cm (ex: -resize 100cm 200cm)
w h can be mm (ex: -resize 100mm 200mm)
w h can be inches (ex: -resize 100i 200i)
-resize fill w h : Scale by filling the box wxh
-resize longest size : Scale longest side
-resize shortest size : Scale shortest side
-resize dpi value : Scale to DPI
-rotate_flag : Rotate flags
smooth : Use smooth rotate
-rotate degrees : Rotate
-saturation red green blue cyan magenta yellow : Saturation (-100...100)
-sepia percent : Sepia
-sharpen percent : Sharpen (1...100)
-shear : Shear
-slice : Slice
-soften percent : Soften (1...100)
-solarize value : Solarize (1...255)
-spread amount : Spread (1...32)
-swap type : Swap component
rbg : RGB->RBG
bgr : RGB->BGR
brg : RGB->BRG
grb : RGB->GRB
gbr : RGB->GBR
-swirl degrees : Swirl (1...360)
-temperature value : Temperature (-100...100)
-tile size : Tile (1...64)
-truecolors
-truecolours : Convert in True Colors
-xflip : Flip horizontal
-yflip : Flip vertical
-unsharp radius amount threshold : Unsharp mask
-waves wavelength phase amount : Waves
wavelength : (1.0 50.0)
phase : (0.0 360.0)
amount : (0.0 100.0)
Available format:
-
- XnThusiast
- Posts: 4172
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: NConvert split images to required width & height using coordinates
Your need to make many crops on a large image without the time delay resulting from loading the source image repeatedly is unusual, and I think your only option using NConvert is probably to consider the several possibilities I have suggested above, in the hope that one might possibly be useful. Note: The multiple crops and outputs in the same line of code possibility didn't work in my test, no surprise.
Are you able to define the problem in a little more detail, do you always need six outputs? And presumably the output image pixel dimensions stated in your first post not the sizes you actually need?
The NConvert version confusion is not unusual, all xnview software is the work of one developer: the use of a checklist when a new version is released has previously been suggested. But it is very unlikely that you have missed any useful new option.
My feeling if you need to process a large number of source images with the same dimensions and required output dimensions, is that the least-bad option might if it is practical be to define an algorithm that minimises run time by as far as possible cropping images that are the result of previous crops.
Are you able to define the problem in a little more detail, do you always need six outputs? And presumably the output image pixel dimensions stated in your first post not the sizes you actually need?
The NConvert version confusion is not unusual, all xnview software is the work of one developer: the use of a checklist when a new version is released has previously been suggested. But it is very unlikely that you have missed any useful new option.
My feeling if you need to process a large number of source images with the same dimensions and required output dimensions, is that the least-bad option might if it is practical be to define an algorithm that minimises run time by as far as possible cropping images that are the result of previous crops.
-
- Posts: 5
- Joined: Fri Nov 24, 2023 11:25 am
Re: NConvert split images to required width & height using coordinates
The sizes is just for example. I want use nconvert for quick visualize big image parts like https://dimin.net/software/panojs/#Demos apps. There is already written apps in python in same app github's and exists alternatives like https://hub.docker.com/r/pblaas/imgcnv. Xnview quickly generate splited images via Create > Split image(s)..., but when I try same thing in nconvert with for loop the result is generating so slow. For example
2561 × 25776 pixels file with 250 tile via 8 level (250x250 lvl1, 500x500 lvl2, ...)
output:1535 image via parallel 8 core = 70 sec ==> single core performance is 1535 / 70 / 8 = 2.74 img/perSec for one image :S
Same thing via Xnview Split image options just in a few second, thousand(s) images is generating.
2561 × 25776 pixels file with 250 tile via 8 level (250x250 lvl1, 500x500 lvl2, ...)
output:1535 image via parallel 8 core = 70 sec ==> single core performance is 1535 / 70 / 8 = 2.74 img/perSec for one image :S
Same thing via Xnview Split image options just in a few second, thousand(s) images is generating.
-
- XnThusiast
- Posts: 4172
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: NConvert split images to required width & height using coordinates
The fastest - least slowest - way using NConvert that I can see would be to create an algorithm that keeps dividing images by two. With the optimum design of loops enabling the reuse of code blocks it might not be too difficult. Start with some degenerate cases such as output to four images, then to eight images, and so on. You would probably need to cascade loops, probably.
However, as the crop switch I think doesn't accept percentages as parameters, for that approach you might look at canvas resize which does, I think.
Or you could maybe check ImageMagick, which has many more options and a forum where you might get more experienced user support.
However, as the crop switch I think doesn't accept percentages as parameters, for that approach you might look at canvas resize which does, I think.
Or you could maybe check ImageMagick, which has many more options and a forum where you might get more experienced user support.
-
- Posts: 5
- Joined: Fri Nov 24, 2023 11:25 am
Re: NConvert split images to required width & height using coordinates
ImageMagick has option with crop like:
Files generated as:
out-0.jpg
out-1.jpg
out-2.jpg
out-3.jpg
Files generated as:
output_0_0.jpg
output_0_1.jpg
output_1_0.jpg
output_1_1.jpg
output_2_0.jpg
output_2_1.jpg
But it is not good for big images, it is filling disk with uncompressed image.
I can't understand, why this option not porting to nconvert from XnView Create > Split image(s)
Code: Select all
convert input.png -crop 512x512 out.jpg"
out-0.jpg
out-1.jpg
out-2.jpg
out-3.jpg
Code: Select all
convert input2.png -crop 512x512 -set filename:tile "%[fx:page.x/512]_%[fx:page.y/512]" +repage "output_%[filename:tile].jpg"
output_0_0.jpg
output_0_1.jpg
output_1_0.jpg
output_1_1.jpg
output_2_0.jpg
output_2_1.jpg
But it is not good for big images, it is filling disk with uncompressed image.
I can't understand, why this option not porting to nconvert from XnView Create > Split image(s)