ImageSource
Raffriff42 (Talk | contribs) m (dangling semicolon;) |
Raffriff42 (Talk | contribs) m (DevIL pixel formats) |
||
(16 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
== ImageReader and ImageSource == | == ImageReader and ImageSource == | ||
− | {{ | + | <div style="max-width:62em" > |
+ | {{Func2Def | ||
|ImageReader(string ''file'', int ''start'', int ''end'', float ''fps'', bool ''use_DevIL'', bool ''info'', string ''pixel_type'') | |ImageReader(string ''file'', int ''start'', int ''end'', float ''fps'', bool ''use_DevIL'', bool ''info'', string ''pixel_type'') | ||
|ImageSource(string ''file'', int ''start'', int ''end'', float ''fps'', bool ''use_DevIL'', bool ''info'', string ''pixel_type'')}} | |ImageSource(string ''file'', int ''start'', int ''end'', float ''fps'', bool ''use_DevIL'', bool ''info'', string ''pixel_type'')}} | ||
:{{Par2|file|string|"c:\%06d.ebmp"}} | :{{Par2|file|string|"c:\%06d.ebmp"}} | ||
− | ::Template for the image file(s), where frame number substitution can be specified using | + | ::Template for the image file(s), where frame number substitution can be specified using [http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/ sprintf syntax]. For example, the files written by [[ImageWriter|ImageWriter's]] default parameters can be referenced with "c:\%06d.ebmp". If {{FuncArg|file}} points to a single file (no sprintf pattern), then that file is read once and the image subsequently returned for all requested frames. |
+ | |||
+ | ::If you see the error message '''''ImageReader: error 'could not open file' in DevIL library''''' it may mean that a {{FuncArg|file}} was not found or does not exist; see [[#Notes|Notes]] below. | ||
:{{Par2|start|int|0}} | :{{Par2|start|int|0}} | ||
Line 18: | Line 21: | ||
:{{Par2|use_DevIL|bool|false}} | :{{Par2|use_DevIL|bool|false}} | ||
− | ::When false, an attempt is made to parse | + | ::When false (the default), give the ''Developer's Image Library'' ([http://openil.sourceforge.net/ DevIL]) lower priority, using the internal BMP/[[ImageWriter#The_EBMP_Format|EBMP]] parser whenever possible; when true, always use DevIL, bypassing the internal parser. |
+ | <div {{NotaBeneWidthIndent|58|4}} > | ||
+ | When {{FuncArg|use_DevIL}}=false, an attempt is made to parse files with the internal BMP/EBMP parser; upon failure – that is, for all image files which are not (E)BMP – [http://openil.sourceforge.net/ DevIL] is utilized. When {{FuncArg|use_DevIL}}=true, execution skips the internal parser and goes directly to DevIL. You should only need to use {{FuncArg|use_DevIL}}=true if you have (E)BMP files you don't want read by '''ImageReader''''s internal parser. See [[#Notes|Notes]] below for DevIL library details. | ||
+ | </div> | ||
:{{Par2|info|bool|false}} | :{{Par2|info|bool|false}} | ||
Line 24: | Line 30: | ||
:{{Par2|pixel_type|string|"RGB24"}} | :{{Par2|pixel_type|string|"RGB24"}} | ||
− | ::Specifies the output pixel format: [[Y8]] (8-bit greyscale), [[RGB24]] and [[RGB32]] are supported. The alpha channel is loaded only for RGB32 and only if DevIL supports it for the loaded image format. | + | ::Specifies the output pixel format: |
+ | ::*If {{FuncArg|use_DevIL}}=true, [[Y8]] (8-bit greyscale), [[RGB24]] and [[RGB32]] are supported. | ||
+ | :::{{AvsPluscon}} also supports their 16-bit counterparts: [[Avisynthplus_color_formats|Y16]], [[Avisynthplus_color_formats|RGB48]] and [[Avisynthplus_color_formats|RGB64]]. | ||
+ | :::The alpha channel is loaded only for RGB32/64 and only if DevIL supports it for the loaded image format. | ||
+ | ::*If {{FuncArg|use_DevIL}}=false, must be empty ''except'' when decoding a 12 bit, 3 plane EBMP; | ||
+ | :::in that case, {{FuncArg|pixel_type}} must be either [[YV12]] (the default) or [[YV411]]. | ||
− | '''ImageReader''' is present from v2.52, replacing [http://www.avisynth.nl/users/warpenterprises/ WarpEnterprises'] plugin. | + | '''ImageReader''' is present from v2.52, replacing [http://www.avisynth.nl/users/warpenterprises/ WarpEnterprises'] ''ImageSequence'' plugin. |
'''ImageSource''' is equivalent, with some minor functionality changes. ImageSource is faster than ImageReader when importing a single picture. | '''ImageSource''' is equivalent, with some minor functionality changes. ImageSource is faster than ImageReader when importing a single picture. | ||
===== ''Output Formats'' ===== | ===== ''Output Formats'' ===== | ||
− | : | + | :For BMP or EBMP images opened with the internal parser, the video output is set when the sequence was created (see [[ImageWriter#The_EBMP_Format|ImageWriter: The EBMP Format]]); for images opened with the [http://openil.sourceforge.net/ DevIL] library, the video output is as decribed under {{FuncArg|pixel_type}} above. |
===== ''Input Formats'' ===== | ===== ''Input Formats'' ===== | ||
:All AviSynth [[Color_spaces|color spaces]] are supported. | :All AviSynth [[Color_spaces|color spaces]] are supported. | ||
− | :[[Wikipedia:BMP_file_format|BMP]] and EBMP | + | :[[Wikipedia:BMP_file_format|BMP]] and EBMP are supported natively (see [[#Notes|Notes]] below); with DevIL 1.7.8, supported image formats are: |
− | + | : [[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:GIF|gif]], [[Wikipedia:OpenEXR|exr]], [[Wikipedia:JPEG_2000|jp2]], [[Wikipedia:Adobe_Photoshop#File_format|psd]], [[Wikipedia:Hierarchical_Data_Format|hdr]], [[Wikipedia:Raw_image_format|raw]], [[Wikipedia:Silicon_Graphics_Image|sgi/bw/rgb/rgba]] |
− | : | + | </div> |
− | + | ||
== ImageSourceAnim == | == ImageSourceAnim == | ||
− | {{ | + | <div style="max-width:62em" > |
+ | {{FuncDef | ||
|ImageSourceAnim(string ''file'', float ''fps'', bool ''info'', string ''pixel_type'')}} | |ImageSourceAnim(string ''file'', float ''fps'', bool ''info'', string ''pixel_type'')}} | ||
:{{Par2|file|string|}} | :{{Par2|file|string|}} | ||
::animation file to be loaded. | ::animation file to be loaded. | ||
+ | |||
+ | ::If you see the error message '''''ImageSourceAnim: error 'could not open file' in DevIL library''''' it may mean that the {{FuncArg|file}} was not found or does not exist; see [[#Notes|Notes]] below. | ||
:{{Par2|fps|float|24.0}} | :{{Par2|fps|float|24.0}} | ||
Line 57: | Line 70: | ||
::When true, the source filename and DevIL version is written to each video frame. | ::When true, the source filename and DevIL version is written to each video frame. | ||
− | :{{Par2|pixel_type|string|" | + | :{{Par2|pixel_type|string|"RGB32"}} |
− | ::Specifies the output pixel format: [[Y8]] (8-bit greyscale), [[RGB24]] and [[RGB32]] are supported. The alpha channel is loaded only for RGB32 and only if DevIL supports it for the loaded image format. | + | ::Specifies the output pixel format: [[Y8]] (8-bit greyscale), [[RGB24]] and [[RGB32]] are supported. |
+ | :::{{AvsPluscon}} also supports their 16-bit counterparts: [[Avisynthplus_color_formats|Y16]], [[Avisynthplus_color_formats|RGB48]] and [[Avisynthplus_color_formats|RGB64]]. | ||
+ | :::The alpha channel is loaded only for RGB32/64 and only if DevIL supports it for the loaded image format. | ||
− | '''ImageSourceAnim''' lets you import animations ([[Wikipedia:GIF|gif]], [[Wikipedia:Netpbm_format|ppm]], [[Wikipedia:TIFF|tif/tiff]] or [[Wikipedia:Adobe_Photoshop#File_format|psd]]). If there is a delay between the first and second image in the animation, the framerate is set accordingly. If this delay is zero, the framerate is set to 24 fps by default (and can be adjusted by setting the {{FuncArg|fps}} parameter) | + | '''ImageSourceAnim''' lets you import animations ([[Wikipedia:GIF|gif]], [[Wikipedia:Netpbm_format|ppm]], [[Wikipedia:TIFF|tif/tiff]] or [[Wikipedia:Adobe_Photoshop#File_format|psd]]). If there is a delay between the first and second image in the animation, the framerate is set accordingly. If this delay is zero, the framerate is set to 24 fps by default (and can be adjusted by setting the {{FuncArg|fps}} parameter). If the images in the animation have unequal dimensions, then the dimension of the first image is taken and the remaining images are padded with black pixels below and or to the right. Note that unlike '''ImageReader''' and '''ImageSource''', {{FuncArg|pixel_type}} is set to RGB32 by default. |
ImageSourceAnim requires DevIL 1.7.8, included in the Avisynth installation (see [[#Notes|Notes]] below). | ImageSourceAnim requires DevIL 1.7.8, included in the Avisynth installation (see [[#Notes|Notes]] below). | ||
+ | </div> | ||
== Examples == | == Examples == | ||
− | + | <div style="max-width:62em" > | |
+ | <div {{BoxWidthIndent|54|0}} > | ||
# Default parameters: read a 1000-frame native AviSynth EBMP sequence (at 24 fps) | # Default parameters: read a 1000-frame native AviSynth EBMP sequence (at 24 fps) | ||
ImageSource() | ImageSource() | ||
+ | </div> | ||
+ | <div {{BoxWidthIndent|54|0}} > | ||
# Read files "100.jpeg" through "199.jpeg" into an NTSC clip | # Read files "100.jpeg" through "199.jpeg" into an NTSC clip | ||
ImageSource("%d.jpeg", 100, 199, 29.97) | ImageSource("%d.jpeg", 100, 199, 29.97) | ||
+ | </div> | ||
+ | <div {{BoxWidthIndent|54|0}} > | ||
# Read files "00.bmp" through "50.bmp" bypassing AviSynth's internal BMP reader | # Read files "00.bmp" through "50.bmp" bypassing AviSynth's internal BMP reader | ||
ImageSource("%02d.bmp", end = 50, use_DevIL = true) | ImageSource("%02d.bmp", end = 50, use_DevIL = true) | ||
+ | </div> | ||
+ | <div {{BoxWidthIndent|54|0}} > | ||
# Read a single image, repeat 300 times | # Read a single image, repeat 300 times | ||
ImageSource("static.png", end = 300, use_DevIL=true) | ImageSource("static.png", end = 300, use_DevIL=true) | ||
+ | </div> | ||
+ | <div {{BoxWidthIndent|54|0}} > | ||
# Read a greyscale (8-bit) jpg: | # Read a greyscale (8-bit) jpg: | ||
ImageSource("GoldPetals-8bit.jpg", use_DevIL=true) | ImageSource("GoldPetals-8bit.jpg", use_DevIL=true) | ||
+ | </div> | ||
+ | <div {{BoxWidthIndent|54|0}} > | ||
# Read a greyscale (8-bit) BMP (using AviSynth's internal BMP reader): | # Read a greyscale (8-bit) BMP (using AviSynth's internal BMP reader): | ||
ImageSource("GoldPetals-8bit.bmp") | ImageSource("GoldPetals-8bit.bmp") | ||
+ | </div> | ||
+ | <div {{BoxWidthIndent|54|0}} > | ||
# Read a YV24 BMP (created with ImageWriter): | # Read a YV24 BMP (created with ImageWriter): | ||
ImageSource("GoldPetals-24bit.ebmp") | ImageSource("GoldPetals-24bit.ebmp") | ||
+ | </div> | ||
+ | <div {{BoxWidthIndent|54|0}} > | ||
# Use a still-frame image with audio: | # Use a still-frame image with audio: | ||
audio = DirectShowSource("Gina La Piana - Start Over.flv") | audio = DirectShowSource("Gina La Piana - Start Over.flv") | ||
− | video = ImageSource("Gina La Piana.jpg", fps=25, start=1, end=ceil(25*AudioLengthF(audio)/AudioRate(audio))) | + | video = ImageSource("Gina La Piana.jpg", fps=25, |
+ | \ start=1, end=ceil(25*AudioLengthF(audio)/AudioRate(audio))) | ||
return AudioDub(video, audio) | return AudioDub(video, audio) | ||
+ | </div> | ||
+ | <div {{BoxWidthIndent|54|0}} > | ||
# Read an animation: | # Read an animation: | ||
ImageSourceAnim("F:\TestPics\8bit_animated.gif") | ImageSourceAnim("F:\TestPics\8bit_animated.gif") | ||
+ | </div> | ||
+ | </div> | ||
== Notes == | == Notes == | ||
+ | <div style="max-width:62em" > | ||
* "EBMP" is an AviSynth extension of the standard Microsoft RIFF image format that allows you to save raw image data (all color formats are supported). See [[ImageWriter#The_EBMP_Format|ImageWriter]] for more details. | * "EBMP" is an AviSynth extension of the standard Microsoft RIFF image format that allows you to save raw image data (all color formats are supported). See [[ImageWriter#The_EBMP_Format|ImageWriter]] for more details. | ||
+ | * Since v2.61 DevIL.dll is delay loaded, so Avisynth.dll can be used without it, in which case ImageReader/Writer would support only ebmp mode. | ||
* Greyscale BMPs are not read and written correctly by DevIL. They should be opened using '''use_DevIL=false'''. | * Greyscale BMPs are not read and written correctly by DevIL. They should be opened using '''use_DevIL=false'''. | ||
− | * [http://openil.sourceforge.net/ DevIL] 1.7.8 is included in the Avisynth installation. If you need to download it, it is available [https://sourceforge.net/projects/openil/files/DevIL%20Win32/1.7.8/DevIL-EndUser-x86-1.7.8.zip here]. Just put the DevIL.dll in your system folder (it will overwrite any older version). Be sure to use the non-unicode version, because the other one will result in crashes when loading pictures. | + | * [http://openil.sourceforge.net/ DevIL] 1.7.8 is included in the Avisynth installation since v2.61. If you need to download it, it is available [https://sourceforge.net/projects/openil/files/DevIL%20Win32/1.7.8/DevIL-EndUser-x86-1.7.8.zip here]. Just put the DevIL.dll in your system folder (it will overwrite any older version). Be sure to use the non-unicode version, because the other one will result in crashes when loading pictures. |
− | *DevIL.dll 1.7.8 requires the 2005 VC | + | *DevIL.dll 1.7.8 requires the 2005 VC [https://support.microsoft.com/en-us/kb/2977003 runtime libraries] to be correctly installed: [http://www.microsoft.com/downloads/details.aspx?familyid=200B2FD9-AE1A-4A14-984D-389C36F85647&displaylang=en Visual C++ 2005 SP1 Redistributable Package (x86)]. |
* Loading DIB/BMP type files that use a palette (such as 8 bit RGB, Monochrome, RLE8 and RLE4) requires DevIL 1.7.8. (Because the failure was usually catastrophic, internal BMP processing does not automatically fail over to DevIL processing. Forcing DevIL processing when using DevIL 1.6.6 for these file types is not recommended.) | * Loading DIB/BMP type files that use a palette (such as 8 bit RGB, Monochrome, RLE8 and RLE4) requires DevIL 1.7.8. (Because the failure was usually catastrophic, internal BMP processing does not automatically fail over to DevIL processing. Forcing DevIL processing when using DevIL 1.6.6 for these file types is not recommended.) | ||
− | + | * Error message for "file not found" condition discussed [https://forum.doom9.org/showthread.php?t=174769 here] | |
+ | </div> | ||
== Changes == | == Changes == | ||
− | + | <div style="max-width:62em" > | |
{| border="1" | {| border="1" | ||
|- | |- | ||
Line 124: | Line 163: | ||
| v2.61 | | v2.61 | ||
| Updated DevIL library to v1.7.8. | | Updated DevIL library to v1.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. | ||
|} | |} | ||
+ | </div> | ||
{{FilterCat|Internal filters|Media file filters|Source_filters}} | {{FilterCat|Internal filters|Media file filters|Source_filters}} |
Latest revision as of 19:50, 3 March 2018
Contents[hide] |
[edit] ImageReader and ImageSource
ImageReader(string file, int start, int end, float fps, bool use_DevIL, bool info, string pixel_type)
ImageSource(string file, int start, int end, float fps, bool use_DevIL, bool info, string pixel_type)
- string file = "c:\%06d.ebmp"
- Template for the image file(s), where frame number substitution can be specified using sprintf syntax. For example, the files written by ImageWriter's default parameters can be referenced with "c:\%06d.ebmp". If file points to a single file (no sprintf pattern), then that file is read once and the image subsequently returned for all requested frames.
- If you see the error message ImageReader: error 'could not open file' in DevIL library it may mean that a file was not found or does not exist; see Notes below.
- int start = 0
- int end = 1000
- Specifies the starting and ending numbers used for filename generation. The file corresponding to start is always frame 0 in the clip, the file corresponding to end is frame (end-start). The resulting clip has (end - start + 1) frames. 'end=0' does NOT mean 'no upper bound' as with ImageWriter. The first file in the sequence, i.e., corresponding to start, MUST exist in order for clip parameters to be computed. Any missing files in the sequence are replaced with a blank frame.
- float fps = 24.0
- Frames Per Second of returned clip.
- bool use_DevIL = false
When use_DevIL=false, an attempt is made to parse files with the internal BMP/EBMP parser; upon failure – that is, for all image files which are not (E)BMP – DevIL is utilized. When use_DevIL=true, execution skips the internal parser and goes directly to DevIL. You should only need to use use_DevIL=true if you have (E)BMP files you don't want read by ImageReader's internal parser. See Notes below for DevIL library details.
- bool info = false
- When true, the source filename and DevIL version is written to each video frame.
- string pixel_type = "RGB24"
ImageReader is present from v2.52, replacing WarpEnterprises' ImageSequence plugin.
ImageSource is equivalent, with some minor functionality changes. ImageSource is faster than ImageReader when importing a single picture.
[edit] Output Formats
- For BMP or EBMP images opened with the internal parser, the video output is set when the sequence was created (see ImageWriter: The EBMP Format); for images opened with the DevIL library, the video output is as decribed under pixel_type above.
[edit] Input Formats
- All AviSynth color spaces are supported.
[edit] ImageSourceAnim
ImageSourceAnim(string file, float fps, bool info, string pixel_type)
- string file =
- animation file to be loaded.
- If you see the error message ImageSourceAnim: error 'could not open file' in DevIL library it may mean that the file was not found or does not exist; see Notes below.
- float fps = 24.0
- Frames Per Second of returned clip.
- bool info = false
- When true, the source filename and DevIL version is written to each video frame.
- string pixel_type = "RGB32"
ImageSourceAnim lets you import animations (gif, ppm, tif/tiff or psd). If there is a delay between the first and second image in the animation, the framerate is set accordingly. If this delay is zero, the framerate is set to 24 fps by default (and can be adjusted by setting the fps parameter). If the images in the animation have unequal dimensions, then the dimension of the first image is taken and the remaining images are padded with black pixels below and or to the right. Note that unlike ImageReader and ImageSource, pixel_type is set to RGB32 by default.
ImageSourceAnim requires DevIL 1.7.8, included in the Avisynth installation (see Notes below).
[edit] Examples
# Default parameters: read a 1000-frame native AviSynth EBMP sequence (at 24 fps) ImageSource()
# Read files "100.jpeg" through "199.jpeg" into an NTSC clip ImageSource("%d.jpeg", 100, 199, 29.97)
# Read files "00.bmp" through "50.bmp" bypassing AviSynth's internal BMP reader ImageSource("%02d.bmp", end = 50, use_DevIL = true)
# Read a single image, repeat 300 times ImageSource("static.png", end = 300, use_DevIL=true)
# Read a greyscale (8-bit) jpg: ImageSource("GoldPetals-8bit.jpg", use_DevIL=true)
# Read a greyscale (8-bit) BMP (using AviSynth's internal BMP reader): ImageSource("GoldPetals-8bit.bmp")
# Read a YV24 BMP (created with ImageWriter): ImageSource("GoldPetals-24bit.ebmp")
# Use a still-frame image with audio: audio = DirectShowSource("Gina La Piana - Start Over.flv") video = ImageSource("Gina La Piana.jpg", fps=25, \ start=1, end=ceil(25*AudioLengthF(audio)/AudioRate(audio))) return AudioDub(video, audio)
# Read an animation: ImageSourceAnim("F:\TestPics\8bit_animated.gif")
[edit] Notes
- "EBMP" is an AviSynth extension of the standard Microsoft RIFF image format that allows you to save raw image data (all color formats are supported). See ImageWriter for more details.
- Since v2.61 DevIL.dll is delay loaded, so Avisynth.dll can be used without it, in which case ImageReader/Writer would support only ebmp mode.
- Greyscale BMPs are not read and written correctly by DevIL. They should be opened using use_DevIL=false.
- DevIL 1.7.8 is included in the Avisynth installation since v2.61. If you need to download it, it is available here. Just put the DevIL.dll in your system folder (it will overwrite any older version). Be sure to use the non-unicode version, because the other one will result in crashes when loading pictures.
- DevIL.dll 1.7.8 requires the 2005 VC runtime libraries to be correctly installed: Visual C++ 2005 SP1 Redistributable Package (x86).
- Loading DIB/BMP type files that use a palette (such as 8 bit RGB, Monochrome, RLE8 and RLE4) requires DevIL 1.7.8. (Because the failure was usually catastrophic, internal BMP processing does not automatically fail over to DevIL processing. Forcing DevIL processing when using DevIL 1.6.6 for these file types is not recommended.)
- Error message for "file not found" condition discussed here
[edit] Changes
v2.60 | Added ImageSourceAnim. |
v2.60 |
|
v2.60 | Opening greyscale images (as Y8) added; EBMP supports all color formats. |
v2.61 | Updated DevIL library to v1.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. |