ImageWriter

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
(add link to avs+ documentation)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''ImageWriter''' writes frames from a clip as a sequence of image files using the DevIL library (except when you choose the internal "ebmp" format).
+
<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.
 
Note that frames are not written to the output file until they are actually rendered by this filter.
Line 23: Line 29:
 
::Set the filename extension and the format of the image.
 
::Set the filename extension and the format of the image.
 
:::The supported values for {{FuncArg|type}} are:
 
:::The supported values for {{FuncArg|type}} are:
:::*[[Wikipedia:BMP_file_format|BMP]] and EBMP ('''ImageWriter''' native format);
+
:::*[[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: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:Netpbm_format|pbm/pgm/ppm]];  [[Wikipedia:TGA|tga]]; [[Wikipedia:TIFF|tif/tiff]];
Line 30: Line 36:
 
:{{Par2|info|bool|false}}
 
:{{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.
 
::When true, overlay progress information on the video clip, showing whether a file is being written, and if so, the filename.
 
  
 
== Examples ==
 
== Examples ==
Line 37: Line 42:
  
 
  # 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.  
 
  # Write frames 100 till the end to "F:\pic-000100.JPEG", "F:\pic-000101.JPEG", etc.  
 
  # and display progress info
 
  # and display progress info
  ImageWriter(file = "F:\pic", start = 100, type = "jpeg", info = true)
+
  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 56: Line 64:
 
  #(thus adding zeros filling two digits)
 
  #(thus adding zeros filling two digits)
 
  ImageWriter(file="F:\%02d.bmp")
 
  ImageWriter(file="F:\%02d.bmp")
 
  
 
== Notes ==
 
== Notes ==
  
Saving as greyscale bmp doesn't work correctly, both for bmp (where DevIL is used) and ebmp (internal parsing). [todo: find out why]
+
* 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 EBMP Format =====
'''ImageWriter''' writes image files using [http://openil.sourceforge.net/ DevIL] (the Developer's Image Library), except when you choose the internal "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]].
 
+
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.
 
For all other image formats (see {{FuncArg|type}} above), the input colorspace '''must''' be Y8, RGB24 or RGB32.
Line 73: Line 78:
 
{| border="1"
 
{| border="1"
 
|-
 
|-
| v2.58
+
| v2.61
| added end=-num_frames
+
| 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 80: 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:Media file filters]]
+
[[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:
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
  • ebmp supports all formats; greyscale added for all formats.
  • add support for printf formating of filename string, default is ("%06d.%s", n, ext).
v2.58 added end=-num_frames
Personal tools