Re: [sane-devel] scanimage / tesseract interoperability

2014-05-19 Thread Jeff Breidenbach
Implementation was a little intrusive because there is no recovery
from calling freopen()  on stdout. This preliminary patch follows
the recommendations of the C FAQ and introduces an explicit
stream variable. I've only done light testing.

http://c-faq.com/stdio/undofreopen.html

$ scanimage --batch 2 /dev/null | cat
out1.pnm
out2.pnm

Cheers,
Jeff


--- /tmp/orig/sane-backends-1.0.23/frontend/scanimage.c 2014-05-12
13:44:40.0 -0700
+++ sane-backends-1.0.23/frontend/scanimage.c 2014-05-12
14:17:18.0 -0700
@@ -1124,7 +1124,8 @@
 }

 static void
-write_pnm_header (SANE_Frame format, int width, int height, int depth)
+write_pnm_header (SANE_Frame format, int width, int height, int depth,
+  FILE *ofp)
 {
   /* The netpbm-package does not define raw image data with maxval  255. */
   /* But writing maxval 65535 for 16bit data gives at least a chance */
@@ -1135,20 +1136,20 @@
 case SANE_FRAME_GREEN:
 case SANE_FRAME_BLUE:
 case SANE_FRAME_RGB:
-  printf (P6\n# SANE data follows\n%d %d\n%d\n, width, height,
+  fprintf (ofp, P6\n# SANE data follows\n%d %d\n%d\n, width, height,
   (depth = 8) ? 255 : 65535);
   break;

 default:
   if (depth == 1)
- printf (P4\n# SANE data follows\n%d %d\n, width, height);
+ fprintf (ofp, P4\n# SANE data follows\n%d %d\n, width, height);
   else
- printf (P5\n# SANE data follows\n%d %d\n%d\n, width, height,
+ fprintf (ofp, P5\n# SANE data follows\n%d %d\n%d\n, width, height,
  (depth = 8) ? 255 : 65535);
   break;
 }
 #ifdef __EMX__ /* OS2 - write in binary mode. */
-  _fsetmode (stdout, b);
+  _fsetmode (ofp, b);
 #endif
 }

@@ -1183,7 +1184,7 @@
 }

 static SANE_Status
-scan_it (void)
+scan_it (FILE *ofp)
 {
   int i, len, first_frame = 1, offset = 0, must_buffer = 0, hundred_percent;
   SANE_Byte min = 0xff, max = 0;
@@ -1273,10 +1274,10 @@
 sanei_write_tiff_header (parm.format,
  parm.pixels_per_line, parm.lines,
  parm.depth, resolution_value,
- icc_profile);
+ icc_profile, ofp);
   else
 write_pnm_header (parm.format, parm.pixels_per_line,
-  parm.lines, parm.depth);
+  parm.lines, parm.depth, ofp);
  }
   break;

@@ -1397,7 +1398,7 @@
   else /* ! must_buffer */
 {
   if ((output_format == OUTPUT_TIFF) || (parm.depth != 16))
- fwrite (buffer, 1, len, stdout);
+ fwrite (buffer, 1, len, ofp);
   else
  {
 #if !defined(WORDS_BIGENDIAN)
@@ -1408,7 +1409,7 @@
 {
   if (len  0)
  {
-  fwrite (buffer, 1, 1, stdout);
+  fwrite (buffer, 1, 1, ofp);
   buffer[0] = (SANE_Byte) hang_over;
   hang_over = -1;
   start = 1;
@@ -1429,7 +1430,7 @@
   len--;
 }
 #endif
-  fwrite (buffer, 1, len, stdout);
+  fwrite (buffer, 1, len, ofp);
  }
 }

@@ -1453,10 +1454,10 @@
   if (output_format == OUTPUT_TIFF)
  sanei_write_tiff_header (parm.format, parm.pixels_per_line,
  image.height, parm.depth, resolution_value,
- icc_profile);
+ icc_profile, ofp);
   else
  write_pnm_header (parm.format, parm.pixels_per_line,
-  image.height, parm.depth);
+  image.height, parm.depth, ofp);

 #if !defined(WORDS_BIGENDIAN)
   /* multibyte pnm file may need byte swap to LE */
@@ -1474,11 +1475,11 @@
  }
 #endif

- fwrite (image.data, 1, image.height * image.width, stdout);
+ fwrite (image.data, 1, image.height * image.width, ofp);
 }

   /* flush the output buffer */
-  fflush( stdout );
+  fflush( ofp );

 cleanup:
   if (image.data)
@@ -1714,6 +1715,7 @@
   SANE_Status status;
   char *full_optstring;
   SANE_Int version_code;
+  FILE *ofp;

   atexit (scanimage_exit);

@@ -2236,12 +2238,15 @@
 format = out%d.pnm;
  }

+  if (!batch)
+ofp = stdout;
+
   if (batch)
  fprintf (stderr,
  Scanning %d pages, incrementing by %d, numbering from %d\n,
  batch_count, batch_increment, batch_start_at);

-  else if(isatty(fileno(stdout))){
+  else if(isatty(fileno(ofp))){
  fprintf (stderr,%s: output is not a file, exiting\n, prog_name);
 exit (1);
   }
@@ -2274,7 +2279,11 @@
 {
   fprintf (stderr, Batch terminated, %d pages scanned\n,
(n - batch_increment));
-  fclose (stdout);
+  if (ofp)
+ {
+  fclose (ofp);
+  ofp = NULL;
+ }
   break; /* get out of this loop */
 }
  }
@@ -2294,19 +2303,27 @@
 {
   fprintf (stderr, %s: sane_start: %s\n,
prog_name, sane_strstatus (status));
-  fclose (stdout);
-  break;
+  if (ofp)
+ {
+  fclose (ofp);
+  ofp = NULL;
+  break;
+ }
 }

+
   /* write to .part file while scanning is in progress */
-  if (batch  NULL == freopen (part_path, w, stdout))
+  if (batch)
+ofp = fopen (part_path, w);
+
+  if (batch  ofp == NULL)
 {
   fprintf (stderr, cannot open %s\n, part_path);
   sane_cancel (device);
   return SANE_STATUS_ACCESS_DENIED;
 }

-  status = scan_it ();
+  status = scan_it (ofp);
   if (batch)
 {
   fprintf (stderr, Scanned page %d., 

[sane-devel] fujitus scansnap ix500 (not found by sane-find-scanner)

2014-05-19 Thread andreo73
Hi,
I'm trying to get a ix500 work on my pc with ubuntu 14.04 freshly installed;
the scanner is attached through usb cable to a usb2 port (my pc has only
usb2 ports)

when the usb cable is first connected (or the scanner is switched on), dmesg
reports

 usb 2-6: new high-speed USB device number 6 using ehci-pci
 usb 2-6: New USB device found, idVendor=04c5, idProduct=132b
 usb 2-6: New USB device strings: Mfr=1, Product=2, SerialNumber=0
 usb 2-6: Product: ScanSnap iX500
 usb 2-6: Manufacturer: Fujitsu

the backend is installed from the debian libsane package (version number
1.0.23-3ubuntu3)

I've modified the fujitsu.conf file appending at the end

#ScanSnap iX500
usb 0x04c5 0x132b

I've also modified /etc/default/saned to have RUN=yes  and restarted with
sudo service saned restart 
(the service starts with no errors)

sane-find-scanner *does not* find anything, even with sudo

sudo scanimage -L remains silend for almost a minute, during which the
scanner's blue light change status, becomes half/orange and flashing ; after
a minute or more, the response is No scanners were identified. 

any suggestion? where to start?

thanks!!




--
View this message in context: 
http://sane.10972.n7.nabble.com/fujitus-scansnap-ix500-not-found-by-sane-find-scanner-tp18666.html
Sent from the SANE - Dev mailing list archive at Nabble.com.

-- 
sane-devel mailing list: sane-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject unsubscribe your_password
 to sane-devel-requ...@lists.alioth.debian.org


Re: [sane-devel] fujitus scansnap ix500 (not found by sane-find-scanner)

2014-05-19 Thread m. allan noah
Upgrade to sane-backends 1.0.24

allan

On Mon, May 19, 2014 at 11:23 AM, andreo73 andrea.bar...@gmail.com wrote:
 Hi,
 I'm trying to get a ix500 work on my pc with ubuntu 14.04 freshly installed;
 the scanner is attached through usb cable to a usb2 port (my pc has only
 usb2 ports)

 when the usb cable is first connected (or the scanner is switched on), dmesg
 reports

  usb 2-6: new high-speed USB device number 6 using ehci-pci
  usb 2-6: New USB device found, idVendor=04c5, idProduct=132b
  usb 2-6: New USB device strings: Mfr=1, Product=2, SerialNumber=0
  usb 2-6: Product: ScanSnap iX500
  usb 2-6: Manufacturer: Fujitsu

 the backend is installed from the debian libsane package (version number
 1.0.23-3ubuntu3)

 I've modified the fujitsu.conf file appending at the end

 #ScanSnap iX500
 usb 0x04c5 0x132b

 I've also modified /etc/default/saned to have RUN=yes  and restarted with
 sudo service saned restart
 (the service starts with no errors)

 sane-find-scanner *does not* find anything, even with sudo

 sudo scanimage -L remains silend for almost a minute, during which the
 scanner's blue light change status, becomes half/orange and flashing ; after
 a minute or more, the response is No scanners were identified. 

 any suggestion? where to start?

 thanks!!




 --
 View this message in context: 
 http://sane.10972.n7.nabble.com/fujitus-scansnap-ix500-not-found-by-sane-find-scanner-tp18666.html
 Sent from the SANE - Dev mailing list archive at Nabble.com.

 --
 sane-devel mailing list: sane-devel@lists.alioth.debian.org
 http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
 Unsubscribe: Send mail with subject unsubscribe your_password
  to sane-devel-requ...@lists.alioth.debian.org



-- 
The truth is an offense, but not a sin

-- 
sane-devel mailing list: sane-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject unsubscribe your_password
 to sane-devel-requ...@lists.alioth.debian.org


[sane-devel] gscan2pdf v1.2.5 released

2014-05-19 Thread Jeffrey Ratcliffe
gscan2pdf - A GUI to produce a multipage PDF or DjVu from a scan.

http://gscan2pdf.sourceforge.net/

Only five clicks are required to scan several pages and then save all or
a selection as a PDF or DjVu file, including metadata if required.

gscan2pdf can control regular or sheet-fed (ADF) scanners with SANE via
libsane-perl, scanimage or scanadf, and can scan multiple pages at
once. It presents a thumbnail view of scanned pages, and permits simple
operations such as cropping, rotating and deleting pages.

OCR can be used to recognise text in the scans, and the output
embedded in the PDF or DjVu.

PDF conversion is done by PDF::API2.

The resulting document may be saved as a PDF, DjVu, multipage TIFF file,
or single page image file.


Changelog for 1.2.5:
* Fix today button on date dialog saving PDF
  Closes bug #171 Today button in calendar jumps to February 1th, 1970
* Fix resolution when processing non-standard sized images with unpaper
* Speed up downsample option by using imagemagick sample instead of resize
* Remove unnecessary decode_utf8() call causing
  'Cannot decode string with wide characters' error in Perl 5.18.
* Add support for tesseract 3.03.
  Closes bug #173 v1.2.4 doesn't display any output
* Fix bug writing images with quotes in filename
  Closes bug #174 Fail to save file when target folder has quote in filename
* Fix setting options which don't cause a reload.
  Closes bug #168 (Resolution Errors on Multiple Scanners)
  Closes bug #170 (Format A2 in PDF properties despite having chosen
A4 while scanning)
  Closes Debian bug #742233 (wrong resolution)
  Closes LP: #1304484 (resolution incorrect, saved pdf far too large)

-- 
sane-devel mailing list: sane-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject unsubscribe your_password
 to sane-devel-requ...@lists.alioth.debian.org


Re: [sane-devel] scanimage / tesseract interoperability

2014-05-19 Thread Jeff Breidenbach
Implemented and tested. Please consider for inclusion.


happy-batch-1.0.diff.gz
Description: GNU Zip compressed data
-- 
sane-devel mailing list: sane-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject unsubscribe your_password
 to sane-devel-requ...@lists.alioth.debian.org

Re: [sane-devel] scanimage / tesseract interoperability

2014-05-19 Thread Jeff Breidenbach
Testing found an error path with a double fclose.
Tiny tweak to make that impossible.

-  if (0 != fclose(ofp))
+  if (!ofp || 0 != fclose(ofp))


names-to-stdout-1.2.diff.gz
Description: GNU Zip compressed data
-- 
sane-devel mailing list: sane-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject unsubscribe your_password
 to sane-devel-requ...@lists.alioth.debian.org