Page 1 of 1
create thumbnail from svg animation
Posted: 2012-01-04T09:33:33-07:00
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
Re: create thumbnail from svg animation
Posted: 2012-01-04T11:55:27-07:00
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
Re: create thumbnail from svg animation
Posted: 2012-01-04T12:31:09-07:00
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....
Re: create thumbnail from svg animation
Posted: 2012-01-04T16:13:24-07:00
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?
Re: create thumbnail from svg animation
Posted: 2012-01-05T07:56:46-07:00
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.
Re: create thumbnail from svg animation
Posted: 2012-01-05T11:19:01-07:00
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
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?
Re: create thumbnail from svg animation
Posted: 2012-01-05T12:29:08-07:00
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.