ruven / iipsrv

iipsrv is an advanced high-performance feature-rich image server for web-based streamed viewing and zooming of ultra high-resolution images.
https://iipimage.sourceforge.io
GNU General Public License v3.0
292 stars 115 forks source link

No DPI in JPEG files generated by IIP #257

Closed olanowak closed 1 year ago

olanowak commented 1 year ago

I have a standard setup of IIP Image Server v1.1-3 (from debian repo) running on HTTPD with default settings. JPEG files generated by the server don't have DPI set in the file metadata (input tif files have it set). I checked both with ImageMagick (identify -verbose) and exiftool. What could be the reason?

ruven commented 1 year ago

I see you also posted to the Slack #IIIF channel. For future reference, here's my reply

I guess you're using the latest Debian or Ubuntu package? The correct DPI is included in all images exported from IIPImage in the current development version. I'm preparing a new release at the moment, which will eventually be available through the default Debian and Ubuntu packages, but this may take some time to filter through. If you wan to fix this quickly you'll need to get the iipsrv source code form github and compile yourself, which is quite straightforward to do.

olanowak commented 1 year ago

Thank you for the answer. Unfortunately it still doesn't work even with https://github.com/ruven/iipsrv/commit/d4e1016a7f1ccb7f830db437fe9866c9d8b7173a

ruven commented 1 year ago

Maybe something wrong with your TIFF file? Can you send me the output of the tiffinfo command?

tiffinfo image.tif

olanowak commented 1 year ago

Sure, here it is:

TIFF Directory at offset 0x868132 (d3f24)
  Image Width: 3756 Image Length: 5598
  Tile Width: 128 Tile Length: 128
  Resolution: 600, 600 pixels/inch
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0:     0   255
     1:   128   255
     2:   128   255
  JPEG Tables: (574 bytes)
TIFF Directory at offset 0x1175372 (11ef4c)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 1878 Image Length: 2799
  Tile Width: 128 Tile Length: 128
  Resolution: 600, 600 pixels/inch
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0:     0   255
     1:   128   255
     2:   128   255
  JPEG Tables: (574 bytes)
TIFF Directory at offset 0x1286104 (139fd8)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 939 Image Length: 1399
  Tile Width: 128 Tile Length: 128
  Resolution: 600, 600 pixels/inch
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0:     0   255
     1:   128   255
     2:   128   255
  JPEG Tables: (574 bytes)
TIFF Directory at offset 0x1325866 (143b2a)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 469 Image Length: 699
  Tile Width: 128 Tile Length: 128
  Resolution: 600, 600 pixels/inch
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0:     0   255
     1:   128   255
     2:   128   255
  JPEG Tables: (574 bytes)
TIFF Directory at offset 0x1339796 (147194)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 234 Image Length: 349
  Tile Width: 128 Tile Length: 128
  Resolution: 600, 600 pixels/inch
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0:     0   255
     1:   128   255
     2:   128   255
  JPEG Tables: (574 bytes)
TIFF Directory at offset 0x1345032 (148608)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 117 Image Length: 174
  Tile Width: 128 Tile Length: 128
  Resolution: 600, 600 pixels/inch
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0:     0   255
     1:   128   255
     2:   128   255
  JPEG Tables: (574 bytes)
TIFF Directory at offset 0x1347362 (148f22)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 58 Image Length: 87
  Tile Width: 128 Tile Length: 128
  Resolution: 600, 600 pixels/inch
  Bits/Sample: 8
  Compression Scheme: JPEG
  Photometric Interpretation: YCbCr
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 3
  Planar Configuration: single image plane
  Reference Black/White:
     0:     0   255
     1:   128   255
     2:   128   255
  JPEG Tables: (574 bytes)
ruven commented 1 year ago

Your tiffinfo output looks fine. Maybe it's simply a cache issue? If you're using Memcached, make sure you empty it's cache and in your navigator, make sure you shift-reload to force a new tile to be sent. If this still doesn't work, take a look in the iipsrv.log file. What does it say when you make an image or tile request (set the VERBOSITY startup variable to 5).

olanowak commented 1 year ago

I don't think it's cache issue :( Here is log file for retireval of a file:


Full Request is IIIF=t255/0903_Przeklad_a_kultura_1_-_0001_wynik_a_Page0000.tif/3584,2304,172,256/86,/0/default.jpg
HTTP Header: If-Modified-Since: Fri, 26 May 2023 21:17:05 GMT
[1/1]: Command / Argument is IIIF : t255/0903_Przeklad_a_kultura_1_-_0001_wynik_a_Page0000.tif/3584,2304,172,256/86,/0/default.jpg
IIIF handler reached
IIIF :: URL decoded to t255/0903_Przeklad_a_kultura_1_-_0001_wynik_a_Page0000.tif/3584,2304,172,256/86,/0/default.jpg
FIF handler reached
FIF :: URL decoding/filtering: t255/0903_Przeklad_a_kultura_1_-_0001_wynik_a_Page0000.tif => t255/0903_Przeklad_a_kultura_1_-_0001_wynik_a_Page0000.tif
FIF :: Image cache initialization
FIF :: TIFF image detected
FIF :: Created image
FIF :: Image dimensions are 3756 x 5598
FIF :: Image contains 3 channels with 8 bits per channel
FIF :: Image timestamp: Fri, 26 May 2023 21:17:05 GMT
FIF :: Unmodified content
FIF :: Total command time 208 microseconds
Sending HTTP 304 Not Modified
Total Request Time: 295 microseconds
image closed and deleted
Server count is 1
ruven commented 1 year ago

It looks like it is indeed a cache problem. This line means that the server is sending back only a HTTP 304 header as the request includes an If-Modifed-Since header:

Sending HTTP 304 Not Modified

So, just do a shift-reload in your navigator for the URL requested in your example and it will force the server to send a new tile:

http://your.server/iipsrv/iipsrv.fcgi?IIIF=t255/0903_Przeklad_a_kultura_1_-_0001_wynik_a_Page0000.tif/3584,2304,172,256/86,/0/default.jpg

If you use exiftool on the resulting JPEG, you should now (hopefully!) see the correct DPI information

olanowak commented 1 year ago

Unfortunately resolution is also missing with the very first (and of course any other) request after starting the server:

IIPImage Server. Version 1.0
*** Ruven Pillay <ruven@users.sourceforge.net> ***

Verbosity level set to 5
Running in FCGI mode

Setting maximum image cache size to 10MB
Setting filesystem prefix to ''
Setting default JPEG quality to 90
Setting maximum CVT size to 5000
Setting HTTP Cache-Control header to 'max-age=86400'
Setting 3D file sequence name pattern to '_pyr_'
Memcached support enabled. Connected to servers: 'localhost' with timeout 86400

Initialisation Complete.
<----------------------------------->

Full Request is IIIF=t255/0903_Przeklad_a_kultura_1_-_0001_wynik_a_Page0000.tif/3584,2304,172,256/86,/0/default.jpg
[1/1]: Command / Argument is IIIF : t255/0903_Przeklad_a_kultura_1_-_0001_wynik_a_Page0000.tif/3584,2304,172,256/86,/0/default.jpg
IIIF handler reached
IIIF :: URL decoded to t255/0903_Przeklad_a_kultura_1_-_0001_wynik_a_Page0000.tif/3584,2304,172,256/86,/0/default.jpg
FIF handler reached
FIF :: URL decoding/filtering: t255/0903_Przeklad_a_kultura_1_-_0001_wynik_a_Page0000.tif => t255/0903_Przeklad_a_kultura_1_-_0001_wynik_a_Page0000.tif
FIF :: Image cache initialization
FIF :: TIFF image detected
FIF :: Created image
FIF :: Image dimensions are 3756 x 5598
FIF :: Image contains 3 channels with 8 bits per channel
FIF :: Image timestamp: Fri, 26 May 2023 21:17:05 GMT
FIF :: Total command time 288 microseconds
IIIF :: Requested Region: x:3584, y:2304, w:172, h:256
IIIF :: Requested Size: 86x128
IIIF :: Requested Rotation: 0 degrees
IIIF :: Requested Quality: default with format: jpg
IIIF :: image request for t255/0903_Przeklad_a_kultura_1_-_0001_wynik_a_Page0000.tif with arguments: region: 3584,2304,172,256; size: 86x128; rotation: 0; mirroring: 0
CVT handler reached
CVT :: Using resolution 5 with size 1878x2799
CVT :: Region: 1792,1152,86,128
CVT :: Requested scaled region size is 86x128 at resolution 5. Nearest existing resolution has region with size 86x128
TileManager getRegion :: Total tiles in image: 15x22 tiles
TileManager getRegion :: Tile start: 14,9 with offset: 0,0
TileManager getRegion :: Tile end: 14,9
TileManager :: Cache Miss for resolution: 5, tile: 149
TileManager :: Cache Size: 0 tiles, 0 MB
TileManager :: Cropping tile
TileManager :: Edge tile: Base size: 128x128: This tile: 86x128
TileManager :: Tile cache insertion time: 34 microseconds
TileManager :: Total Tile Access Time: 277 microseconds
TileManager getRegion :: Tile access time 282 microseconds for tile 149 at resolution 5
TileManager getRegion :: destination tile width: 86, tile height: 128
CVT :: About to JPEG compress strip with height 128
CVT :: Compressed data strip length is 908
CVT :: Total command time 465 microseconds
IIIF :: Total command time 830 microseconds
Memcached :: stored 1176 bytes in 16 microseconds
Total Request Time: 1379 microseconds
image closed and deleted
ruven commented 1 year ago

Your log file says:

IIPImage Server. Version 1.0

So, you're not starting up the right executable. It should say version 1.2

olanowak commented 1 year ago

Indeed, unfrotunately I messed up my Dockerfile :(

In the upgrade to 1.2 helped. Help you for your help :)