ImageWriter
(add link to avs+ documentation) |
|||
(12 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | {{ | + | <div {{BlueBox2|40|0|3px solid purple}} > |
+ | {{AvsPlusFullname}}<br> | ||
+ | Up-to-date documentation: [https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/corefilters/imagewriter.html https://avisynthplus.readthedocs.io] | ||
+ | </div> | ||
− | |||
− | '' | + | '''ImageWriter''' writes frames from a clip as a sequence of image files using the [http://openil.sourceforge.net/DevIL library] (except when you choose the internal "ebmp" format). |
− | '' | + | Note that frames are not written to the output file until they are actually rendered by this filter. |
+ | __NOTOC__ | ||
+ | |||
+ | == Syntax and Parameters == | ||
+ | {{Template:FuncDef | ||
+ | |ImageWriter(clip ''clip'', string ''file'', int ''start'', int [-]''end'', string ''type'', bool ''info'')}} | ||
− | ''type'' default | + | :{{Par2|file|string|"c:\"}} |
+ | ::The path + filename prefix of the saved images. | ||
+ | ::The images will have file names with the pattern: ''{{FuncArg|file}}000000.{{FuncArg|type}}, {{FuncArg|file}}000001.{{FuncArg|type}}, ''etc. | ||
+ | ::[http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/ Sprintf] formatting of the filenames is supported. | ||
+ | ::By default, images will be saved as ''C:\000000.ebmp, C:\000001.ebmp,'' etc. | ||
− | + | :{{Par2|start|int|0}} | |
− | :( | + | :{{Par2|end|int|0}} |
− | : | + | ::The start and end of the frame range that will be written. |
+ | ::They both default to 0 (where {{FuncArg|end}}=0 means last frame). | ||
+ | ::If {{FuncArg|end}} is negative, it specifies the number of frames that will be written. | ||
− | + | :{{Par2|type|string|"ebmp"}} | |
+ | ::Set the filename extension and the format of the image. | ||
+ | :::The supported values for {{FuncArg|type}} are: | ||
+ | :::*[[Wikipedia:BMP_file_format|bmp]] and ebmp ('''ImageWriter''' native format); | ||
+ | :::* [[Wikipedia:DirectDraw_Surface|dds]]; [[Wikipedia:JPEG|jpg/jpe/jpeg]]; [[Wikipedia:PCX|pcx]]; [[Wikipedia:Portable_Network_Graphics|png]]; | ||
+ | :::*[[Wikipedia:Netpbm_format|pbm/pgm/ppm]]; [[Wikipedia:TGA|tga]]; [[Wikipedia:TIFF|tif/tiff]]; | ||
+ | :::*[[Wikipedia:Raw_image_format|raw]]; [[Wikipedia:Silicon_Graphics_Image|sgi/bw/rgb/rgba]] | ||
− | + | :{{Par2|info|bool|false}} | |
+ | ::When true, overlay progress information on the video clip, showing whether a file is being written, and if so, the filename. | ||
− | + | == Examples == | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
# Export the entire clip in the current native AviSynth format | # Export the entire clip in the current native AviSynth format | ||
ImageWriter("D:\backup-stills\myvideo") | ImageWriter("D:\backup-stills\myvideo") | ||
# Write frame 5 to "C:\000005.PNG" | # Write frame 5 to "C:\000005.PNG" | ||
+ | ImageWriter(start = 5, end = 5, "png") | ||
+ | |||
+ | # Write frame 5 to "000005.PNG" into the current directory | ||
ImageWriter("", 5, 5, "png") | ImageWriter("", 5, 5, "png") | ||
− | # Write frames 100 till the end to "F:\pic-000100.JPEG", "F:\pic-000101.JPEG", etc. and display progress info | + | # Write frames 100 till the end to "F:\pic-000100.JPEG", "F:\pic-000101.JPEG", etc. |
− | ImageWriter(file = "F:\pic", start = 100, type = "jpeg", info = true) | + | # and display progress info |
+ | ImageWriter(file = "F:\pic-", start = 100, type = "jpeg", info = true) | ||
# Write a jpg as greyscale (note the luma range should be [0,255], not [16,235]) | # Write a jpg as greyscale (note the luma range should be [0,255], not [16,235]) | ||
Line 41: | Line 61: | ||
ImageWriter("F:\TestPics\GoldPetals-24bit", type = "ebmp") | ImageWriter("F:\TestPics\GoldPetals-24bit", type = "ebmp") | ||
− | # Write all frames to "F:\00.bmp", "F:\01.bmp", ..., "F:\10.bmp", "F:\11.bmp", ..., "F:\100.bmp", ... (thus adding zeros filling two digits) | + | # Write all frames to "F:\00.bmp", "F:\01.bmp", ..., "F:\10.bmp", "F:\11.bmp", ..., "F:\100.bmp", ... |
+ | #(thus adding zeros filling two digits) | ||
ImageWriter(file="F:\%02d.bmp") | ImageWriter(file="F:\%02d.bmp") | ||
− | + | == Notes == | |
− | + | * Greyscale BMPs are not written correctly by DevIL (the luma is written to all three channels instead of a single channel). They should be written as ebmp. | |
− | ''' | + | ===== The EBMP Format ===== |
+ | The internal image format "ebmp" supports all color spaces. The "ebmp" files written from the [[RGB]] or [[Y8]] color spaces are standard BMP files, but those produced from [[YUV]] spaces are special and can probably only be read by AviSynth's [[ImageSource]]. This special format allows you to save and reload raw video in any [[Color_spaces|color space]]. | ||
+ | |||
+ | For all other image formats (see {{FuncArg|type}} above), the input colorspace '''must''' be Y8, RGB24 or RGB32. | ||
+ | |||
+ | == Changelog == | ||
{| border="1" | {| border="1" | ||
|- | |- | ||
− | | v2. | + | | v2.61 |
− | | | + | | DevIL library updated to 1.7.8. |
+ | |- | ||
+ | | v2.61 | ||
+ | | DevIL.dll is now delay loaded, so Avisynth.dll can be used without it, in which case ImageReader/Writer would support only ebmp mode. | ||
|- | |- | ||
| v2.60 | | v2.60 | ||
Line 59: | Line 88: | ||
* ebmp supports all formats; greyscale added for all formats. | * ebmp supports all formats; greyscale added for all formats. | ||
* add support for printf formating of filename string, default is ("%06d.%s", n, ext). | * add support for printf formating of filename string, default is ("%06d.%s", n, ext). | ||
+ | |- | ||
+ | | v2.58 | ||
+ | | added end=-num_frames | ||
|} | |} | ||
[[Category:Internal filters]] | [[Category:Internal filters]] | ||
− | [[Category: | + | [[Category:Export_Filters]] |
Latest revision as of 06:29, 18 September 2022
AviSynth+
Up-to-date documentation: https://avisynthplus.readthedocs.io
ImageWriter writes frames from a clip as a sequence of image files using the library (except when you choose the internal "ebmp" format).
Note that frames are not written to the output file until they are actually rendered by this filter.
[edit] Syntax and Parameters
ImageWriter(clip clip, string file, int start, int [-]end, string type, bool info)
- string file = "c:\"
- The path + filename prefix of the saved images.
- The images will have file names with the pattern: file000000.type, file000001.type, etc.
- Sprintf formatting of the filenames is supported.
- By default, images will be saved as C:\000000.ebmp, C:\000001.ebmp, etc.
- int start = 0
- int end = 0
- The start and end of the frame range that will be written.
- They both default to 0 (where end=0 means last frame).
- If end is negative, it specifies the number of frames that will be written.
- string type = "ebmp"
- Set the filename extension and the format of the image.
- The supported values for type are:
- bmp and ebmp (ImageWriter native format);
- dds; jpg/jpe/jpeg; pcx; png;
- pbm/pgm/ppm; tga; tif/tiff;
- raw; sgi/bw/rgb/rgba
- The supported values for type are:
- Set the filename extension and the format of the image.
- bool info = false
- When true, overlay progress information on the video clip, showing whether a file is being written, and if so, the filename.
[edit] Examples
# Export the entire clip in the current native AviSynth format ImageWriter("D:\backup-stills\myvideo")
# Write frame 5 to "C:\000005.PNG" ImageWriter(start = 5, end = 5, "png")
# Write frame 5 to "000005.PNG" into the current directory ImageWriter("", 5, 5, "png")
# Write frames 100 till the end to "F:\pic-000100.JPEG", "F:\pic-000101.JPEG", etc. # and display progress info ImageWriter(file = "F:\pic-", start = 100, type = "jpeg", info = true)
# Write a jpg as greyscale (note the luma range should be [0,255], not [16,235]) ImageSource("F:\TestPics\GoldPetals.jpg") ConvertToY8(matrix="PC.601") ImageWriter("F:\TestPics\GoldPetals-8bit-avs", type = "png")
# Write a jpg as YV24 ebmp (note the luma range should be [0,255], not [16,235]) ImageSource("F:\TestPics\GoldPetals.jpg") ConvertToYV24(matrix="PC.601") ImageWriter("F:\TestPics\GoldPetals-24bit", type = "ebmp")
# Write all frames to "F:\00.bmp", "F:\01.bmp", ..., "F:\10.bmp", "F:\11.bmp", ..., "F:\100.bmp", ... #(thus adding zeros filling two digits) ImageWriter(file="F:\%02d.bmp")
[edit] Notes
- Greyscale BMPs are not written correctly by DevIL (the luma is written to all three channels instead of a single channel). They should be written as ebmp.
[edit] The EBMP Format
The internal image format "ebmp" supports all color spaces. The "ebmp" files written from the RGB or Y8 color spaces are standard BMP files, but those produced from YUV spaces are special and can probably only be read by AviSynth's ImageSource. This special format allows you to save and reload raw video in any color space.
For all other image formats (see type above), the input colorspace must be Y8, RGB24 or RGB32.
[edit] Changelog
v2.61 | DevIL library updated to 1.7.8. |
v2.61 | DevIL.dll is now delay loaded, so Avisynth.dll can be used without it, in which case ImageReader/Writer would support only ebmp mode. |
v2.60 |
|
v2.58 | added end=-num_frames |