create thumbnail from svg animation

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
jstph
Posts: 31
Joined: 2011-01-27T10:07:43-07:00
Authentication code: 8675308

create thumbnail from svg animation

Post by jstph »

magic,
I can convert regular svg to PNG. When I try to create a PNG thumbnail from an animated svg, the results image only show a corner of the original svg. Is there anything special I need to do.

this is the test file I have used.
http://upload.wikimedia.org/wikipedia/c ... imated.svg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: create thumbnail from svg animation

Post by fmw42 »

What was your command line to extract a thumbnail? Are you trying to get one image or an animated image for the thumbnail? Please clarify further so others can test. By the way, png does not support multi-frame images, so no animation. If you want to convert to an animation use gif.

Have you tried this?

convert Soccer_ball_animated.svg[0] Soccer_ball_animated_0.png
jstph
Posts: 31
Joined: 2011-01-27T10:07:43-07:00
Authentication code: 8675308

Re: create thumbnail from svg animation

Post by jstph »

Thanks for reply.

I don't use command line. I use IM as a library. My thumbnail has to be in PNG format. So I understand I will lost the animation ability. I expect to get the whole vector drawing without the animation section. however, it looks like IM only return the last animation drawing as the result image.

the following code is an example how I convert image.

//read image
ImageInfo* _imageInfo = AcquireImageInfo();
ExceptionInfo* exception = AcquireExceptionInfo();
char* _inputImageFormat= "svg";
int size = strlen(_inputImageFormat)+1;
memcpy(_imageInfo->magick, _inputImageFormat, size);
SetImageInfoFile(_imageInfo, "Soccer_ball_animated.svg");
Image* _image = ReadImage(_imageInfo, exception);

//write image
char* format = "png";
ImageInfo* iinfo = AcquireImageInfo();
memcpy(iinfo->magick, format, strlen(format)+1);
size_t blobsize = 0;
ExceptionInfo* aexception = AcquireExceptionInfo();
BYTE* blob = ImageToBlob(iinfo, _image, &blobsize, aexception);
//.... then save the blob to output file....
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: create thumbnail from svg animation

Post by fmw42 »

Sorry I don't use any APIs, just command line so I cannot tell you how to do either. In command line, I thought I was getting the first frame, but I see now that there does not seem to be any unique frames available to IM. IM is taking something, perhaps the first or last effective frame of the animation. I do not know enough about svg animations to tell you how to handle that. All I can suggest is that you edit the svg file to generate only one still image. Do you need an image for every frame? If not, then what difference does it make whether you get the first or last image from the animation to use as a thumbnail?
jstph
Posts: 31
Joined: 2011-01-27T10:07:43-07:00
Authentication code: 8675308

Re: create thumbnail from svg animation

Post by jstph »

Fmw42, I always appreciate your help. My knowledge about svg is also limited. From my understanding, the animation of svg is just a set of vector drawing, which constantly repaints on main frame (it also is a set of vector drawing) to create the animation effect. I want the result PNG include that main frame. Right now, my results image only has the animation drawing without main frame in it. It seems like IM only returns me the “delta” image, not the whole image.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: create thumbnail from svg animation

Post by fmw42 »

I don't know what to tell you as I don't know your API. However, when I simply convert the svg to png, I get the whole image for one frame of the animation.

convert Soccer_ball_animated.svg Soccer_ball_animated.png

Image

Do I misunderstand what you are trying to produce for your output? Is my example above what you want?

If so, it is either something you are doing wrong in your code or something with your version or installation of IM? What version of IM are you using?
jstph
Posts: 31
Joined: 2011-01-27T10:07:43-07:00
Authentication code: 8675308

Re: create thumbnail from svg animation

Post by jstph »

you get it right. that image is what I want.

From the way I called, I only get one animation frame.
http://imageshack.us/photo/my-images/845/npro.png
My guess is I missed some attribute setup in the ImageInfo object, when I call ReadImage. I checked all attributes in ImageInfo object and couldn't figure out which one to set.
Post Reply