Writing webp takes huge time

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Locked
gegupta
Posts: 30
Joined: 2010-12-03T12:14:09-07:00
Authentication code: 8675308

Writing webp takes huge time

Post by gegupta »

Hi,

I am trying to compare between the timing it takes to convert(including resize) from jpeg->webp or jpeg->jpeg or webp->webp. I am doing this for jpg and webp versions of the same image.

I am using
ImageMagick version: 6.8.6-8
webp version : 0.4.2(I tried 0.4.1 too)
OS : Ubuntu

Currently through my application i am timing the operations(read,resize,write) separately:

Code: Select all

timeval tim;
gettimeofday(&tim, NULL);
double t11=tim.tv_sec+(tim.tv_usec/1000000.0);
image_.resize( boost::lexical_cast<string>(context.getTargetWidth())+"x"+ boost::lexical_cast<string>(context.getTargetHeight()) + "!");
gettimeofday(&tim, NULL);
double t12=tim.tv_sec+(tim.tv_usec/1000000.0);
float tResize = (t12-t11)*1000;

Code: Select all

timeval tim1;
gettimeofday(&tim1, NULL);
double tWriteStart=tim1.tv_sec+(tim1.tv_usec/1000000.0);
image_.write(fileName_.c_str());
gettimeofday(&tim1, NULL);
double tWriteEnd=tim1.tv_sec+(tim1.tv_usec/1000000.0);
float tWriteFile = (tWriteEnd - tWriteStart)*1000;
Sample case :
convert A.jpg -resize 1200x1200 B.webp
convert A.webp -resize 1200x1200 C.webp
Sample image : https://ebay.box.com/s/rhh3t81r5lb9bzclznsircgjlqakchaj (Please let me know if that link is accessible by you). Unfortunately this forum doesnt give me option to attach files :(

The time to write file(Image.write) is very high as the target size grows. Many times it is more than the time it took to resize.

I did a sample study on 2000 images and result on an average is same as i described. Have you seen this kind of behaviour in any of your benchmarkings?

I have filed a similar request in the past for gif : viewtopic.php?f=1&t=24329&p=104273#p104273 because you guys suggested to use n option to optimize it. Does anything similar applies to the webp too?

Please let me know if anymore clarifications are required.

Thanks

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: Writing webp takes huge time

Post by magick »

We could not download your image without creating an account. Instead we created a 5000x3750 image as follows:
  • -> convert logo: -resize 5000x5000 A.jpg

    -> convert logo: -resize 5000x5000 A.webp

    -> time convert A.jpg -resize 1200x1200 B.webp
    1.764u 0.132s 0:00.46 410.8% 0+0k 0+112io 0pf+0w

    -> time convert A.webp -resize 1200x1200 C.webp
    1.780u 0.129s 0:00.52 365.3% 0+0k 0+56io 0pf+0w
The timing seems reasonable to us. We're using ImageMagick 6.9.0-7.

gegupta
Posts: 30
Joined: 2010-12-03T12:14:09-07:00
Authentication code: 8675308

Re: Writing webp takes huge time

Post by gegupta »

Hi,

Is it the same if you use the APIs? I am kind of more concerned regarding the writing of the images. My usecase reads an image from a location(my case /dev/shm), processes it(resizes it) and then writes it back to the same location. i have timers around the same.

This is similar to example in the following : http://www.imagemagick.org/Magick++/Image.html
Image image;
image.read("myImage.tiff");
image.addNoise(GaussianNoise);
image.write("myImage.tiff");

So, what i noticed was that "image.write" was taking more time.

Thanks
Geetanjali

gegupta
Posts: 30
Joined: 2010-12-03T12:14:09-07:00
Authentication code: 8675308

Re: Writing webp takes huge time

Post by gegupta »

Hi,

I was wondering if you got a chance to look at the following. Please let me know if i am mistaken anywhere.

Thanks for help!
geetanjali

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: Writing webp takes huge time

Post by magick »

Magick++ and the command-line both are wrappers to the same MagickCore API calls. They should have nearly identical timing results. If you want us to try your code in our local environment to see if the problem is associated with your environment, post a minimal Magick++ codeset that we can download and compile. We'll need a sample image as well. If we see sluggishness, as you suggest, we will be in a better position to debug the problem. Right now, reading / writing WebP seems to be fast for us.

Locked