help with dynamic JPEG

Help
Rinkan
2007-11-23
2012-10-06
  • Rinkan
    Rinkan
    2007-11-23

    I just installed IIPImage server over windows.
    Great job and very fast images generation.

    I saw in the "clients" page that is possible to use this application to generate dynamics JPEGs: "It is also possible to embed links to dynamically generate JPEG images in a web page using the IIP protocol CVT=JPEG command to generate an image of the desired width."

    In fact I cant get the image at the desired resolution. Every time I set the WID size I get one similar but not the exact one I ask for.

    for example:
    <a href="http://127.0.0.1/fcgi-bin/iipsrv.fcgi?FIF=/tmp/test.tif&WID=400&CVT=JPEG">Link</a>
    And get an image of 400px of width
    But if I change the WID parameter to "420":
    <a href="http://127.0.0.1/fcgi-bin/iipsrv.fcgi?FIF=/tmp/test.tif&WID=420&CVT=JPEG">Link</a>
    I get the same image (@ 400 px of with instead of 420)
    
    I have tested this with several resolutions (WID) and founded that the image change only with some wid values.
    Wid Value   Image result width
    1000    : 1000 px
    1100    : 1000 px
    1500    : 1400px
    
    Is it possible to generate an image which obtain a particular resolution? What am I doing wrong?
    

    Thanks in advance

     
    • Willy Lee
      Willy Lee
      2008-07-01

      So if I were to pass the current state to ImageMagick, is there some easy way to get the state of the window out to that script? Ideally, I'd like to pass the zoom level, the height and width and the offset from the top left corner.

      (Thanks for some awesome work by the way...)

       
      • Ruven
        Ruven
        2008-07-17

        Well all these parameters are available within the javascript. It depends what you mean by "easy" ;) What exactly are you trying to do? Allow a user to click a button and export the image via imagemagick or something? In which case, yes it would be easy to create a GET or POST request to send to imagemagick.

         
    • Ruven
      Ruven
      2007-11-23

      In fact the image size you get is the nearest available resolution to that which you request. Resolutions are generated within the TIFF at divisions of 2 of the full resolution. i.e. full resolution, 1/2, 1/4, 1/8, 1/16 ... etc. So, you cannot get precise arbitrary sizes, I'm afraid. I'll update the documentation to make this clearer.

      If this functionality is critical, you could pass the image generated by iipsrv through imagemagick to perform the final refinement. Or are these images to be used within a web page? In this case, you could use CSS to force the image size to what you want.

      It wouldn't be too complicated to add such functionality to iipsrv. I haven't included it so far as it would add a large processing overhead to each CVT request. But I may add it to a future release.

      Yours,
      Ruven

       
      • DGSL
        DGSL
        2007-11-23

        Like rinkan, I was also surprised the first time I used the CVT parameter because I couldn't get the exact width I requested.
        Nonetheless, there are many tricks to get the exact image size by other means. Apart from the solution posted by Ruven -which affects the image "apparent" size-, there are ways to affect its "real" size:
        - For example, I get it using the GD graphics library included in PHP (and available for many other languages): http://www.php.net/gd
        - Also, you can transform the size of your IIPimage-generated-jpeg using imagemagick or vips at script runtime.

        I agree with rinkan that it is more comfortable that IIPimage server makes all this work for you, but I agree with Ruven that -if this is gonna slow down the server speed- I wouldn't change it at all.
        I would change it only if this "large processing overhead" is optional (i.e., server only uses this "exact image size" functionality if you explicitly requests it at runtime).
        The real interest of this wonderful software is how fast it serves really big images.

        That's my opinion: I would like the server to be more functional, but I need it to be fast. So don't make it more functional if this makes it slower.


        I think this subject is somehow related to another question I would like to address:

        -How far we are to see a new version of IIPimage server capable to serve JPEG images? (I mean, the original being a JPEG, not a pyramidal TIFF)
        -Is there any risk that this new functionality also makes the server be slower? Or only slower for jpegs?
        I explain: if I have a server with let's say 50% pyramidal tiffs and 50% jpegs, the "new version" of the server would serve 100% of my images more slowly, or only those which are in jpeg format? (I hope the tiff viewing speed will keep on being the same ... if not faster ;)

        Well, I suppose I always can make a decision at runtime, have 2 versions of the server installed and, if the original image in my database is a jpeg, I can call the new server, but if it is a pyramidal tiff, I call the old one.

         
        • Ruven
          Ruven
          2007-11-26

          OK guys, I think it should be possible to have it do an exact image resizing that is only slower if explicitly requested, but that remains fast otherwise. I'll try to include this functionality in the next release. Also intended for the next release is JPEG source image support. Sure, it'll be a lot slower than TIFF as JPEGs cannot be tiled or be multi-resolution etc. but it will be possible to use both JPEG and TIFF without degrading TIFF performance. I hope to have this ready for Christmas or early in the new year :-)

           
  • Clint Thurman
    Clint Thurman
    2009-11-10

    Ruven,

    You said: "OK guys, I think it should be possible to have it do an exact image
    resizing that is only slower if explicitly requested, but that remains fast
    otherwise. I'll try to include this functionality in the next release."

    Has there been any progress on this? I see on the IIPImage "About" page it
    says: "Instant dynamic generation of JPEG overviews or details at any
    resolution."

    I'm in dire need of such a solution and would much prefer this functionality
    to come bundled in with the server. However, if it hasn't made it into a
    release yet, do f you have suggestions on how to accomplish this? Any details
    would be greatly appreciated.

    Thanks,
    Clint

     
  • Ruven
    Ruven
    2009-11-10

    Yes, exact resizing is now working. It uses a very fast nearest neighbour
    resampling for sizes between the resolution layers. You can get it now from
    the svn repository!

     
  • Clint Thurman
    Clint Thurman
    2009-11-10

    Thanks, that's terrific news! I'm currently using 0.9.7. Is the trunk in
    stable enough condition for a production (live) environment?

     
  • Ruven
    Ruven
    2009-11-10

    Yes, the current svn is production ready. We are currently using it for our
    demo servers.

     
  • Clint Thurman
    Clint Thurman
    2009-11-11

    Thanks again. Is there something that I need to add to the QueryString to
    force this resizing? I've tried "file.tif&wid=400&cvt=jpeg" but it still sends
    back the nearest image in the pyramid, which for me is 250x250.

     
  • Ruven
    Ruven
    2009-11-12

    No, it should work with your query string. Make sure you are running the
    version from svn. The logfile should tell you that you are running version
    0.9.8.

     
  • Clint Thurman
    Clint Thurman
    2009-11-12

    You've been great with you prompt replies, thank you so much for that! Looks
    like the test images maxed out at 250x250, so when I asked for anything above
    that it just served up the 250, which seems like the right thing to do.

    I am noticing though, that in some instances, say when I have a 2000x2000 and
    I ask for a 170x170 to be returned, I get the correctly sized image but it
    contains a one pixel high artifact along the bottom of the image. Some
    requested image sizes return the artifact and some do not. Do you have any
    thoughts on this?

    Thanks for all the help!!!

     
  • DGSL
    DGSL
    2009-11-12

    I am using 0.9.8 svn, though I have compiled on a different Ubuntu machine
    (not the one that is running the iipsrv.fcgi).

    Regarding the one pixel artifact, I also found this: when I request a certain
    "WID=X&CVT=jpeg", the image properties I see (IExplorer and mouse right
    button) are X-1 wide (so one pixel less wide than requested).
    I don't know if this is the same "one pixel high artifact" mentioned by
    clint9090, or a different problem.

    Apart from that, this is more relevant for me: there seems to be an upper
    limit, as you can see from my results:

    Requested (width obtained):
    WID=1 (ERROR);
    WID=2 (1);
    WID=3 (2);
    WID=10 (9);
    WID=700 (699);
    WID=1090 (1089);
    WID=1091 (1090);
    WID=1092 (1092);
    WID=1093 (1092);
    WID=1094 (1092);
    WID=1500 (1092);
    WID=3000 (1092);

    Oddly, there is no way to obtain a 1091 pixels wide image (following this
    sequence I would expect 1091 when using WID=1092).
    But 1092 is the only case that I got exactly the requested size. Also, 1092
    seems to be an "upper limit" of what I can obtain using CVT.

    The biggest jpeg I can get is 1092x1650, but the image I used is a pyramidal
    tiff obtained from a 4369x6603 pixels wide tiff (image properties on Windows
    explorer: 4369x6603x24b)

    I converted it to ptif using the last version of vips for Windows, wih this
    command:

    vips im_vips2tiff original.tif tiled.ptif:deflate,tile:256x256,pyramid

    But I don't know how to see the image properties of the produced pyramidal tif
    (to check that it still is 4369 pixels wide) ... just to confirm that the
    "upper 1092 limit" is a problem of iipsrv or a problem of the image (the same
    happens with many other images, as my vips command runs from a batch script).
    Perhaps this line in apache2.conf has something to do?

    -initial-env MAX_CVT=3000

    (I cant see the relation between 3000 and 1092x1650):


    Apart from all this, since we are talking about vips, I would ask Ruven about
    the future enhancement of iipserver to handle jpeg2000:

    Is it possible to produce jpeg2000 using vips? I would like to keep on using
    it now that I have a ready way to produce my tiled images :)

     
  • Ruven
    Ruven
    2009-11-12

    The 1 pixel difference / artefact is due to rounding in the resizing. CVT
    streams the output image 1 strip at a time (each strip is a row of tiles)
    which have a fixed height. Sometimes this ends up with difference of 1 pixel
    at the bottom.

    The resampling code is in src/CVT.cc. If anyone has a suggestion on how to
    improve this, don't hesitate to tell me!

     
  • Ruven
    Ruven
    2009-11-12

    (I cant see the relation between 3000
    and 1092x1650):

    The 3000 limit is the maximum dimension in either direction. So, the next
    resolution up after 1092x1650 is 2184x3300 which is too big. What is happening
    is that the maximum is being wrongly applied to the resolution layer, not the
    user requested size. I will fix this.

    Is it possible to produce jpeg2000
    using vips? I would like to keep on
    using it now that I have a ready way
    to produce my tiled images :)

    No, vips cannot generate JPEG2000 images.

     
  • DGSL
    DGSL
    2009-11-12

    Thanks, mistery solved.

    Now some off-topic ...

    In case we can't expect future vips versions to convert to jpeg2000 ... which
    free conversion utility would you suggest for fast and low memory consumption
    in a Windows environment?
    I just need something equivalent to "vips im_vips2tiff" and nothing else. Well
    ... perhaps something:

    When converting TIFFs or JPEGs to tiled formats, what happens with EXIF data?
    I presume these tiled formats are not supported by image libraries currently
    used by server scripting languages such as PHP ... but perhaps with an
    external application accessed by shell commands.

    I would be interested in accessing to it in order to pass to the client viewer
    application, for example (i.e., scanner resolution is necessary for me to
    calculate the pixels/mm ratio so I can pass the "scale:" option to
    iipmooviewer)

    What would you suggest as the best approach to this?

    Many thanks in advance

     
  • Ruven
    Ruven
    2009-11-12

    There will be plenty of information about conversion software when the server
    is released.

    I think vips now extracts some EXIF information automatically during
    conversion. Personally, I use something called exiftool to extract both EXIF
    and IPTC data and re-inject into the TIFF.

     
  • DGSL
    DGSL
    2009-12-09

    First of all, I think I found an error in iipimage server responses under
    certain conditions:

    I want to combine usage of RGN and WID/HEI parameters in order to get parts of
    the image of a given size. So I tried this way:

    http://mysite.com/fcgi-bin/iipsrv.fcgi?FIF=/mypath/myfile.ptif&WID=500&RGN=0.45,0.75,0.55,0.25&
    CVT=
    JPEG

    I am getting the part of the image I need (right bottom) but the file produced
    has not the expected size (500 pixels wide ... or 499 if there is some
    rounding). Instead, I am getting a small file (274 pixels wide). But actually,
    WID is having some proportional effect (if I request WID 300, I get 164; if I
    double my request to 600, I get 329). I always get about 55% of requested
    width
    .

    If I change the WID to the end of my URL, then I get a big file (2339 pixels
    wide) so the WID parameter seems to have no effect if it goes after CVT.

    OK. If you look at my requested URL, I am trying to get a image portion which
    is a 55% of the original image width. So it seems to me that there is a
    misunderstanding of this parameter, since the percentage is also being applied
    to the WID numeric value.

    I tried this, and yes: the bigger is the 3rd valued passed in RGN, the error
    in WID is smaller. This is how it should work:

    WID=npixels&RGN=a,b,c,d

    All a,b,c,d are numbers between 0 and 1.
    Only when c equals 1, iipimage serves the requested size (npixels)
    So, this is how it is working:

    WID=npixels*c&RGN=a,b,c,d

    I guess this is an error. Or perhaps I am misunderstanding the usage of RGN
    parameters?


    All above, tested under the latest version of IIPimage server. And here is my
    other question:

    Yesterday I tried the iipimage-0.9.8.deb file (by the way, it's so small).
    I am still not very used to installing in Ubuntu (apart from using apt-get
    way), so I googled to see how to install a .deb file. I guess I should use
    dpkg command:

    But after doing it, I got a message saying I was missing the libfcgi library.
    So I did apt-get install libfcgi, and then again dpkg -i
    iipimage-0.9.8.deb

    Finally I got this small file in /usr/lib/cgi-bin:

    -rwxr-xr-x 1 root root 166532 2009-12-07 15:48 iipsrv.fcgi

    I copied it to my fastcgi apache folder, give execution privileges, and
    restarted Apache. It didn't work.

    I realized this file was rather small compared to the near 2 MB I used to have
    in that folder. So I updated my sources from svn, and recompiled. Now it works
    (and the compiled file size is again near 2 MB). All my tests with WID / RGN
    requests where made with this compiled version.

    Any hints about how should I install the .deb file? Why do I get such a small
    file?

    Many thanks in advance

     
  • Ruven
    Ruven
    2009-12-29

    In fact the deb binary is dynamically linked to libfcgi making it slightly
    smaller than usual. So you need to make sure this is installed in your system.
    When you compile manually yourself, it will statically link it in if you don't
    have libfcgi installed.

     


Anonymous


Cancel   Add attachments