Log in

View Full Version : ImageMagick Reader / Writer for AviSynth v1.60


Pages : [1] 2 3 4 5

Wilbert
16th March 2008, 17:24
This plugin consists of two filters: ImmaRead and ImmaWrite. The former reads images and the latter writes images to your hard drive.

ImmaRead supports the following formats:

* bmp, bmp3/4, dds, dpx, gif, jng, jpg, jp2, mng, pam, pbm, pcx, pgm, png, pnm, ppm, psd, svg (partial), tga, tiff, webp and wmf;
* formats with an alpha channel: gif, jng, png and tiff;
* gif and mng animations, multipage ppm and tiff, multilayer psd;
* 8 bit grayscale images (any alpha channel that is present is dropped);
* vector images: eps, pdf and ps (you need to install GhostScript, for example 8.64 (gs864w32.exe) or more recent; might be convienient to install GhostView (gsv50w32.exe) too although that's not necessary);
* raw camera support (3FR, CR2, DCR, DNG, ERF, MEF, MRW, NEF, ORF, PEF, RAF, SR2 and X3F) (you need to copy the patched version of dcraw.exe which is included in this package in a folder, say C:\Program Files (x86)\dcraw, and add the folder as a PATH system variable in the environmental variables).

Note that raw files are not supported by ImmaRead, since they can be opened by the plugin RawSource.

ImmaWrite supports the following formats:

* bmp, bmp3/4, dds, dpx, gif, jng, jpg, jp2, mng, pam, pbm, pcx, pgm, png, pnm, ppm, psd (only one layer?), svg (partial), tga, tiff, webp and wmf;
* formats with an alpha channel: gif, jng, png and tiff;
* gif, mng and psd animations, multipage ppm and tiff;
* 8 bit grayscale (with or without an alpha channel) images;
* raw images: either RGB or YCbCr depending on the input (for YCbCr with the following order of the planes: Y,U,V);
* YUV4MPEG (y4m): 4:2:2, 4:4:4, 4:2:2, 4:2:0mpeg2, 4:1:1 and mono are supported as planar formats with the following order of the planes: Y,U,V [see y4m: http://wiki.multimedia.cx/index.php?title=YUV4MPEG2; http://linux.die.net/man/5/yuv4mpeg];
* vector images: eps/eps2/eps3, pdf and ps/ps2/ps3.

Note that ImmaWrite doesn't support svg, wmf, raw digital photos or multi-layer psd.

Grayscale images are opened as Y8. RGB images are opened as RGB32 (when there is an alpha channel present) or as RGB24 (if there is no alpha channel present). Other formats (such as CMYK) are converted to RGB.

You need the ImageMagick dll's (http://www.wilbert.dijkhof.com) in order to be able to use this plugin. They should be copied to some folder (any folder will do). You need to set the MAGICK_HOME variable to the location of ImageMagick dll's (under Settings -> System -> Advanced -> Environment Variables -> Add MAGICK_HOME as a user variable), or you need to provide it using the magick_home argument. Thus for example, magick_home = "C:\\WINNT\\system32".

Changelog in v1.60:

* updated to AVISYNTH_INTERFACE_VERSION = 6 (so the plugin requires AviSynth v2.60).
* updated ImageMagick libraries to v7.0.2-10 (ported code to MagickCore API 7.0).
* ImmaRead: grayscale images are opened as Y8, non-grayscale images as RGB24 (or RGB32 if there is an alpha channel present).
* ImmaWrite: added dithering methods "Riemersma" and "FloydSteinberg".
* ImmaWrite: added the new 2.6 colorformats for raw/y4m.
* ImmaWrite: the color option is changed to color_max.
* ImmaWrite: added quality and sampling_factor options for jpeg.
* ImmaWrite: added the compression option.

Enjoy ;-)

download:
* plugin: http://www.wilbertdijkhof.com/Immaavs_v160.zip
* ImageMagick dll's: http://www.wilbertdijkhof.com/ImageMagick-7.0.2_dll.zip (copy the dll's and xml files to your 32-bit system folder)

mikeytown2
17th March 2008, 03:40
So this is, in it's current form, just like ImageSource() (http://avisynth.org/mediawiki/ImageSource) but on steroids!
If i ever wanted to update this Plugin with a new version of imagemagick (http://www.imagemagick.org/script/binary-releases.php#windows) how easy would that be?
In the future, would it be possible to use the imagemagick library as another filter. So i could use imagemagick's image processing in my script? would i ever want to do this?

I downloaded the zip and extracted everything. I tried running this in the Release folder but it says 'LoadPlugin: unable to load "immaavs.dll" '
LoadPlugin("immaavs.dll")
Immaread("goldpetals.gif")
All 28 files from the zip are in the Release folder including the above 2 files. Timestamp of the dll is 3/16/2008 2:49PM


Thanks for your time!

ps u might want to change the title in the htm doc to something other then ColorMatrix :p

Wilbert
17th March 2008, 22:23
If i ever wanted to update this Plugin with a new version of imagemagick how easy would that be?
It took me ages to get it working on my PC. But it still has to work on yours using the dll's alone :)

You need to recompile ImageMagick (all libs and dlls), and after that you need to recompile the plugin (linking against some of the libs).

I downloaded the zip and extracted everything. I tried running this in the Release folder but it says 'LoadPlugin: unable to load "immaavs.dll" '
Crap. I guess copying all dlls to your system folder doesn't help?

Could you try the following command-line utility:

http://www.geocities.com/wilbertdijkhof/core2.zip

It converts format X into format Y.

1) copy all dlls in your system folder.
2) open a dos prompt, go to the folder you put core2.exe in and type: core2.exe goldpetals.jpg test.bmp

It should convert your jpg to test.bmp. Does that work?

mikeytown2
17th March 2008, 22:52
Here are some screen shots. They might help
http://img401.imageshack.us/img401/7927/screenshotcg5.th.png (http://img401.imageshack.us/my.php?image=screenshotcg5.png)
http://img508.imageshack.us/img508/9118/screenshot2dp3.th.png (http://img508.imageshack.us/my.php?image=screenshot2dp3.png)

Edit
Looks like the zip doesn't have CORE_RL_xlib.dll in it

McCauley
17th March 2008, 23:04
Hi Wilbert,

thanks for this plugin.
Is there a chance that ImageMagick will support the DNG format in the near future? That would be great, because one could use a RAW converter without Photoshop to convert DNG to a compatible format. That would be a tremendously useful feature for Stop Motion movies.

Regards
McCauley

Wilbert
17th March 2008, 23:49
Edit
Looks like the zip doesn't have CORE_RL_xlib.dll in it
Here's a package with some more dlls:

http://www.geocities.com/wilbertdijkhof/core2.zip

Could you try core2.exe again?

Is there a chance that ImageMagick will support the DNG format in the near future? That would be great, because one could use a RAW converter without Photoshop to convert DNG to a compatible format. That would be a tremendously useful feature for Stop Motion movies.
Perhaps. The list with supported formats http://www.imagemagick.org/script/formats.php says the following about it:

"Requires an explicit image format otherwise the image is interpreted as a TIFF image (e.g. dng:image.dng)."

I'm not sure what it means. Does it work in E-Male's own plugin?

mikeytown2
18th March 2008, 01:05
2 More screen shots
http://img255.imageshack.us/img255/8241/screenshot3pu9.th.png (http://img255.imageshack.us/my.php?image=screenshot3pu9.png)
http://img187.imageshack.us/img187/7481/screenshot4dk7.th.png (http://img187.imageshack.us/my.php?image=screenshot4dk7.png)

If we can't figure this out in a couple of days i could let u mstsc into my box. I use it on the go.
http://www.kood.org/terminal-server-patch/


BTW time stamp of core2.exe is on the 9th with this latest zip.
And there are only 2 files in the zip

squid_80
18th March 2008, 05:46
Wilbert: core_rl_magick_.dll seems to have dependencies on:

CORE_RL_BZLIB_.DLL
CORE_RL_LCMS_.DLL
CORE_RL_XLIB_.DLL
CORE_RL_ZLIB_.DLL
which all seem to be missing.

Archimedes
18th March 2008, 11:33
A possibility to do some image editing would be very nice. ;-)

For example, resizing without gamma errors.

1. Convert to 16 bit format
2. Set gamma = 1/2.2
3. Resize
4. Set gamma = 2.2
5. Convert to 8 bit format

Wilbert
18th March 2008, 20:25
@mikeytown2,

Sorry, i put up the wrong zip file. Here's the correct one:

http://www.geocities.com/wilbertdijkhof/core2_dll.zip

These are precisely the ones that squid_80 mentioned. Could you try it again?

mikeytown2
18th March 2008, 20:45
@mikeytown2,

Sorry, i put up the wrong zip file. Here's the correct one:

http://www.geocities.com/wilbertdijkhof/core2_dll.zip

These are precisely the ones that squid_80 mentioned. Could you try it again?

It works, the resulting bmp file looks good.

Wilbert
18th March 2008, 21:26
It works, the resulting bmp file looks good.
Great! What about the plugin? Can you get that to work?

mikeytown2
20th March 2008, 04:39
It works when i have these 32 files in the same dir
http://img228.imageshack.us/img228/6360/screenshoptpv2.th.jpg (http://img228.imageshack.us/my.php?image=screenshoptpv2.jpg)

Wilbert
20th March 2008, 22:11
Great! Thanks for the confirmation!

Wilbert
23rd March 2008, 18:03
Updated to v1.2 and this time all necessary dll's are included.

changelog:

* added several new formats (like tga, jng, mng, pcx and wmf);
* support for animated formats where the images have different sizes.

Wilbert
23rd March 2008, 18:05
@McCauley,
Is there a chance that ImageMagick will support the DNG format in the near future? That would be great, because one could use a RAW converter without Photoshop to convert DNG to a compatible format. That would be a tremendously useful feature for Stop Motion movies.
I get strange error messages when trying to open some dng files i found on the internet. I will ask the ImageMagick devs what the status of dng support is.

mikeytown2
23rd March 2008, 20:37
@McCauley
If you are looking for any alt to photoshop's RAW converter, try http://www.xnview.com/ it's been helpful to me multiple times; although they don't mention DNG on their website. Wikipedia says that DNG http://en.wikipedia.org/wiki/Digital_Negative_%28file_format%29 is supported in ImageMagick. http://www.imagemagick.org/discourse-server/viewtopic.php?t=8113
http://www.adobe.com/products/dng/supporters.html

mikeytown2
26th March 2008, 23:03
The ImageMagick libraries are updated to v6.3.8-11

Quick question, which version is this?
v6.3.8-1 or v6.3.9-0
http://www.imagemagick.org/script/changelog.php

Wilbert
26th March 2008, 23:15
Quick question, which version is this?
v6.3.8-1 or v6.3.9-0
http://www.imagemagick.org/script/changelog.php
It's not on the list :confused: I guess it's from the 18/19th of February. I will update them again next time!

Wilbert
2nd April 2008, 21:28
I put a new version up before i start with write support!

Changelog:

* updated ImageMagick library to v6.4.0;
* added dds;
* added support for raw digital photos [see docs for its usage].

Wilbert
18th April 2008, 23:07
New version (v1.30) out with write support!

Wilbert
20th May 2008, 16:24
If anybody is still interested. v1.31 contains animation/multipage write support. Next version will have read/write sequence support.

edit: Does anyone know whether alpha is supported in BMP3? ImageMagick automatically creates BMP4 when feeding RGB32 (and BMP3 for RGB24), but i'm not convinced that alpha is not supported in BMP3.

Archimedes
20th May 2008, 21:51
This package includes some ImageMagick dll's which are needed to use this plugin. They need to be in the same folder as the pictures you want to open (for some reason, putting them into your system folder doesn't work).
Do you also offer a static build? Copying the pictures to the ImageMagick DLL folder are not allways very comfortable.

gzarkadas
21st May 2008, 04:00
Do you also offer a static build? Copying the pictures to the ImageMagick DLL folder are not allways very comfortable.

You can put the image magic dlls in the system32 folder and just copy the avisynth script inside the images folder, so that you can use filenames without paths when calling Imma... functions (if you use paths you will get an error).

Just tested with Immaread; had immaavs.dll in another folder, image magick dlls in system32 and used various jpeg images in various folders.

@Wilbert,
The problem has to do with path handling, but I don't know exactly where; I may have time to search deeper later.

Wilbert
21st May 2008, 21:59
You can put the image magic dlls in the system32 folder and just copy the avisynth script inside the images folder, so that you can use filenames without paths
Yes, that works :) Thanks !!!

@Wilbert,
The problem has to do with path handling, but I don't know exactly where; I may have time to search deeper later.
Let me know if you have figured this out!

Do you also offer a static build? Copying the pictures to the ImageMagick DLL folder are not allways very comfortable.
I still have to figure out how to do that :) gzarkadas, how do i do that? Do i need to add all ImageMagick libs (not just CORE_RL_magick_.lib) as lib modules in the link tab of the project settings? Or do I need to add all the libs to the project (Add to Project -> Files), just as i did with the source files.

gzarkadas
21st May 2008, 23:22
...Do i need to add all ImageMagick libs (not just CORE_RL_magick_.lib) as lib modules in the link tab of the project settings?...

Yes, all 49 libs :) (that's the number of dlls I counted with IM_MOD_... dlls included; a lot of work :p) - at Configuration properties | Linker | Input | Additional Dependencies. This will create a large dll; around 6MB.

I will send a PM with some of my test-runs; they may be of use.

Wilbert
27th May 2008, 23:26
Version 1.32 is out.

Changelog:

* changed license from "GPL v2 or later" to "GPL V2" (in order to be able to use sequence support from ImageReader/ImageWriter and AppyMessage);
* ImmaWrite: added sequence writing;
* fixed the path problem (by changing the working directory internally to the place of the image(s) and passing only the filename to the ImageMagick libs; won't work for W98) (thanks gzarkadas!);
* ImmaRead: added sequence reading and info;
* added the necessary info for compiling this plugin.

Syntax:

ImmaRead (string filename, int start, int end, bool animation, bool info)
ImmaWrite (string filename, int start, int end, string type, string mode, bool animation)

Archimedes
28th May 2008, 12:14
fixed the path problem
:thanks:

LoadDLL doesn't work, so have to copy the ImageMagick dll's to the program directory of Fritz Photo ( http://forum.gleitz.info/showthread.php?t=33835). This works now.

Is there a way to tell immaavs where to find the ImageMagick dll's (as a new parameter)? It's because, i like to copy all dll's in a subfolder of the program directory.

Wilbert
28th May 2008, 12:21
LoadDLL doesn’t work
Yes i know, but i don't know why.

Is there a way to tell immaavs where to find the ImageMagick dll's (as a new parameter)? It's because, i like to copy all dll's in a subfolder of the program directory.
What don't you include that subfolder as PATH environment variable?

Archimedes
28th May 2008, 12:33
The program itself should work without any changes to the system configuration (only AviSynth have to be installed). Is there a way within AviSynth to do that (setting a path environment for dll's)? If no, i will live with the dll’s in the main directory. That was the reason (handling of the dll's), why i asked for a static build.

Wilbert
28th May 2008, 12:44
Is there a way within AviSynth to do that (setting a path environment for dll's)? If no, i will live with the dll’s in the main directory.
I will ask Stickboy to add this to his GetSystemEnv plugin :)

stickboy
30th May 2008, 09:28
Okay, but it might take me a couple of days since I don't have a build environment set up anymore.

tacman1123
1st June 2008, 14:18
This was originally a question about installing immaavs, I've deleted the question but will provide the answer to anyone who comes across this thead.

immaavs is dependent on the ImageMagick dlls, which must be installed in the system directory. Those dlls can be found at

http://www.geocities.com/wilbertdijkhof/ImageMagick_dll.zip

Wilbert -- maybe add a README file to the zip that includes this?

Thanks for providing this great tool!

Tac

Wilbert
1st June 2008, 14:27
You need to put the following dll's:
http://www.geocities.com/wilbertdijkhof/ImageMagick_dll.zip
in your system folder, and immaavs.dll in your plugin folder. Does that work?

stickboy
9th June 2008, 11:25
I've updated my GetSystemEnv plug-in (http://www.avisynth.org/stickboy/) to include a SetWorkingDir function. Sorry for the delay. Let me know if there are any problems.

Archimedes
9th June 2008, 14:23
I can’t benefit from SetWorkingDir so far. My working directory has to be the program directory. All plugins, libaries and DLL’s are in sub folders under the program directory. A typical script looks like this (simple example with Rotate):

LoadPlugin("plugins\Rotate\Rotate.dll")

Import("lib\FritzPhoto\FritzPhoto.avs")

#------------
angle = 1.0
width = 0
height = 0
color = 0
#------------

isYV12() ? YV12toRGB() : last
Rotate(angle, width, height, color)
As you can see, i’m working with relative path names.

Wilbert
9th June 2008, 16:40
I guess i need to make a static build then.

Maxiuca
21st June 2008, 23:20
I've tried plugin today to load a sequence of TIFFs but unfortunatelly the image sequence reading does not work properly.

For example if you use file matrix like "name.%04d.tif" and "start=1000, end=3000" parameters, the plugin will just read first 2000 tiffs starting from "name.0000.tif" and ending with "name.1999.tif" instead of reading from "name.1000.tif" to "name.3000.tiff"

Wilbert
21st June 2008, 23:31
For example if you use file matrix like file.%04d.tif and "start=1000, end=3000" parameters, the plugin will just read first 2000 tiffs starting from file.0000.tif and ending with file.1999.tif
I'll report the bug to the author of this plugin in the other thread.
Thanks for the bugreport! I will fix it for the next release.

Mug Funky
22nd June 2008, 06:00
that's weird - i could have sworn i read an image sequence that way a few days ago. i may have been using vanilla imagesource though.

btw - write support is the bomb. i can make dpx's directly now, and with a little finessing can maintain timecodes in the filenames (though the headers are all stamped 00:00:00:00 and the files are flagged as log, i can work around this). thanks heaps Wilbert! being able to work from a mov in pc range saved my arse (and the highlights/shadows).

mikeytown2
22nd June 2008, 07:21
In this next release, do you think you could add wild card support?
http://forum.doom9.org/showthread.php?t=109997

Comatose
24th June 2008, 19:02
When type="gif" and animated=true, it doesn't seem to be doing anything.

Wilbert
25th June 2008, 11:25
When type="gif" and animated=true, it doesn't seem to be doing anything.
Upon reading or writing? When writing an animated gif you should play the script, the animation is written when the last (selected) frame is played.

In this next release, do you think you could add wild card support?
It's on the todo list, but it won't be in the next release. I'm not sure yet if it would be convenient to include also subfolder scanning (or only scanning of the current folder). But scanning of the current folder i want to include anyway.

Comatose
25th June 2008, 11:36
Writing. I played it with and without start= and end= in MPC set to play once, just to be sure, but nothing.
I ended up just saving individual GIFs and "muxing" them them into an animated GIF with unfreez.

Um, could you add an option for disabling dithering? In anime, there usually is banding (post denoise) and most of the time it's small enough to not be noticeable but the dithering makes ugly, off colored dancing grain.

Wilbert
25th June 2008, 11:59
Ok. I will look at it on saturday.

IanB
25th June 2008, 14:25
@Comatose,

Dithering is inevitable if you save a full colour image in any restricted color format like GIF. Either save to a full color format like JPEG, or filter your clip so each frame only has fewer or equal unique colours than the format supports, e.g. N <= 256 for GIF. And I am not aware of any AVS filters specifically for reducing the unique colour count but tricks with Levels, Tweak, ColorYUV or RGBAdjust may be possible. Other filters that may also be able to be adapted.

Leak
25th June 2008, 19:21
Actually, GIF can contain more than 256 colors (http://en.wikipedia.org/wiki/GIF#True_color), just not in the same frame. But using several frames with 0 delay in-between means you can have more than 256 colors at the same time... :)

Not that I'd advocate actually using this, mind you.

np: Sage Francis - Keep Moving (Human The Death Dance)

smok3
25th June 2008, 21:21
could all this lead to openEXR support, and HDR support generaly speaking?

Comatose
25th June 2008, 22:09
@Comatose,

Dithering is inevitable if you save a full colour image in any restricted color format like GIF. Either save to a full color format like JPEG, or filter your clip so each frame only has fewer or equal unique colours than the format supports, e.g. N <= 256 for GIF. And I am not aware of any AVS filters specifically for reducing the unique colour count but tricks with Levels, Tweak, ColorYUV or RGBAdjust may be possible. Other filters that may also be able to be adapted.
Can't dithering be disabled? I'm pretty sure I used something to save a GIF a long time ago and I could disable dithering.

It's something the compressor does voluntarily, no? That grain doesn't appear out of nowhere >:3

IanB
26th June 2008, 00:28
@Comatose,

You have to do something to reduce the number of distinct colours to the level the format supports. The IM library used here dithers. What would you like it to do? And as I said if you preprocess your image to reduce the number of distinct colours present it will not dither.