Bug 119110 - Saving resolution info in Images
Summary: Saving resolution info in Images
Status: RESOLVED FIXED
Alias: None
Product: kooka
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: OpenSUSE Linux
: NOR wishlist with 25 votes (vote)
Target Milestone: ---
Assignee: Klaas Freitag
URL:
Keywords:
: 129645 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-12-28 12:04 UTC by Bastian Frank
Modified: 2007-07-17 23:09 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bastian Frank 2005-12-28 12:04:42 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    SuSE RPMs
OS:                Linux

I found that all images saved with Kooka (at least JPEG and PNG) miss the resolution information at which they were scanned. This is very annoying when trying to print an image at a later time when the original resolution is not known any more.

Both formats are able to hold this information, in PNG the "pHYs"-Block (http://www.w3.org/TR/PNG/#11pHYs) explicitly allows to set the correct resolution for the picture.

It seems that other applications in KDE also lack support for these resolution fields in images, as even pictures with correctly set resolution fields print at 72 dpi. (I tested this with CorelDraw, which reads, writes and uses this information correctly.)

There are several other bug reports with similar, but not equal, wishes; so this might be a very useful feature.
Comment 1 Gilles Schintgen 2006-04-09 12:25:41 UTC
The Gimp complains about wrong resolution info in files created by Kooka. "Resolution out of bounds"
Comment 2 MaxiPunkt 2006-07-18 21:08:25 UTC
Hey, I think this is the same bug here:
http://bugs.kde.org/show_bug.cgi?id=129645
Comment 3 Helge Hielscher 2007-02-20 23:27:00 UTC
*** This bug has been confirmed by popular vote. ***
Comment 4 Martin Koller 2007-07-17 23:04:48 UTC
*** Bug 129645 has been marked as a duplicate of this bug. ***
Comment 5 Martin Koller 2007-07-17 23:09:12 UTC
SVN commit 689188 by mkoller:

BUG: 119110
Correctly retrieve the x/y scan resolution and store it
into the scanned image


 M  +28 -9     kscandevice.cpp  


--- branches/KDE/3.5/kdegraphics/libkscan/kscandevice.cpp #689187:689188
@@ -60,12 +60,13 @@
 {
 public:
     KScanDevicePrivate()
-	: currScanResolution(0)
+	: currScanResolutionX(0),
+	  currScanResolutionY(0)
 	{
 	    
 	}
 
-    int currScanResolution;
+    int currScanResolutionX, currScanResolutionY;
     
 };
 
@@ -788,13 +789,16 @@
    }
 
    /* Set scan resolution for preview. */
-   if( optionExists( SANE_NAME_SCAN_Y_RESOLUTION ) )
+   if( !optionExists( SANE_NAME_SCAN_Y_RESOLUTION ) )
+      d->currScanResolutionY = 0;
+   else
    {
       KScanOption yres ( SANE_NAME_SCAN_Y_RESOLUTION );
       /* if active ? */
       storeOptions->backupOption( yres );
       yres.set( set_dpi );
       apply( &yres );
+      yres.get( &d->currScanResolutionY );
 
       /* Resolution bind switch ? */
       if( optionExists( SANE_NAME_RESOLUTION_BIND ) )
@@ -811,8 +815,10 @@
    apply( &res );
 
    /* Store the resulting preview for additional image information */
-   res.get( &d->currScanResolution );
+   res.get( &d->currScanResolutionX );
 
+   if ( d->currScanResolutionY == 0 )
+      d->currScanResolutionY = d->currScanResolutionX;
 
    /* Start scanning */
    KScanStat stat = acquire_data( true );
@@ -914,6 +920,18 @@
  	        kdDebug(29000) << "Option <" << so->getName() << "> is not active !" << endl;
  	    }
  	}
+
+	/** Scan Resolution should always exist. **/
+	KScanOption res( SANE_NAME_SCAN_RESOLUTION );
+	res.get( &d->currScanResolutionX );
+        if ( !optionExists( SANE_NAME_SCAN_Y_RESOLUTION ) )
+           d->currScanResolutionY = d->currScanResolutionX;
+        else
+        {
+           KScanOption yres( SANE_NAME_SCAN_Y_RESOLUTION );
+           yres.get( &d->currScanResolutionY );
+        }
+
 	return( acquire_data( false ));
     }
     else
@@ -1169,13 +1187,14 @@
     if( status == KSCAN_OK && img )
     {
 	ImgScanInfo info;
-	/* FIXME: Both resolutions are equal here but should be
-	 *        x and y different
-	 */
-	info.setXResolution(d->currScanResolution);
-	info.setYResolution(d->currScanResolution);
+	info.setXResolution(d->currScanResolutionX);
+	info.setYResolution(d->currScanResolutionY);
 	info.setScannerName(shortScannerName());
 
+	// put the resolution also into the image itself
+	img->setDotsPerMeterX(static_cast<int>(d->currScanResolutionX / 0.0254 + 0.5));
+	img->setDotsPerMeterY(static_cast<int>(d->currScanResolutionY / 0.0254 + 0.5));
+
 	if( scanningPreview )
 	{
 	    kdDebug(29000) << "Scanning a preview !" << endl;