soliloque has proposed merging lp:~soliloque/simple-scan/remove_ps_tiff into
lp:simple-scan.
Commit message:
Remove code for ps and tiff support
Requested reviews:
Robert Ancell (robert-ancell)
For more details, see:
https://code.launchpad.net/~soliloque/simple-scan/remove_ps_tiff/+merge/322607
The file chooser dialog offers three format for saving files: PNG, JPEG, and
PDF. I consider this is the right thing to do as it covers pretty much every
use cases: PDF for having all images in a single file, JPEG for having compact
files at the price of using lossy compression, and PNG for retaining all
scanned pixels, maybe for further editing with another software.
Double-clicking a page in simple-scan will open it with an image viewer.
However, this feature wasn't following what the file chooser dialog does as it
saves the image in the TIFF format. For this feature to be in line with the
file chooser dialog, I changed the image format used from TIFF to PNG. TIFF
offers nothing over PNG for what Simple-Scan does anyway and PNG is more widely
supported than TIFF at this time. This make the code for supporting TIFF file
format useless.
There is also code for supporting PostScript file format. This format doesn't
offer anything over PDF -- PDF is in fact better as it supports icc profiles.
Furthermore, PDF is vastly more widely supported than PDF. As simple-scan
doesn't use or offer to save in PostScript, this code isn't useful too.
So, to summarize, this merge would remove the code -- and the need to maintain
that code -- supporting PostScript and TIFF file formats without removing any
feature or usefulness to Simple-Scan.
--
Your team Simple Scan Development Team is subscribed to branch lp:simple-scan.
=== modified file 'src/book.vala'
--- src/book.vala 2017-03-29 09:40:01 +0000
+++ src/book.vala 2017-04-16 11:22:38 +0000
@@ -165,34 +165,6 @@
}
}
- private void save_ps_pdf_surface (Cairo.Surface surface, Gdk.Pixbuf image, double dpi)
- {
- var context = new Cairo.Context (surface);
- context.scale (72.0 / dpi, 72.0 / dpi);
- Gdk.cairo_set_source_pixbuf (context, image, 0, 0);
- context.get_source ().set_filter (Cairo.Filter.BEST);
- context.paint ();
- }
-
- private void save_ps (File file) throws Error
- {
- var stream = file.replace (null, false, FileCreateFlags.NONE, null);
- var writer = new PsWriter (stream);
- var surface = writer.surface;
-
- for (var i = 0; i < n_pages; i++)
- {
- var page = get_page (i);
- var image = page.get_image (true);
- var width = image.width * 72.0 / page.dpi;
- var height = image.height * 72.0 / page.dpi;
- surface.set_size (width, height);
- save_ps_pdf_surface (surface, image, page.dpi);
- surface.show_page ();
- saving (i);
- }
- }
-
private uint8[]? compress_zlib (uint8[] data)
{
var stream = ZLib.DeflateStream (ZLib.Level.BEST_COMPRESSION);
@@ -598,12 +570,8 @@
{
case "jpeg":
case "png":
- case "tiff":
save_multi_file (type, quality, file);
break;
- case "ps":
- save_ps (file);
- break;
case "pdf":
save_pdf (file, quality);
break;
=== modified file 'src/page.vala'
--- src/page.vala 2015-09-13 21:35:37 +0000
+++ src/page.vala 2017-04-16 11:22:38 +0000
@@ -676,14 +676,6 @@
keys[2] = null;
writer.save (image, "png", keys, values);
}
- else if (strcmp (type, "tiff") == 0)
- {
- string[] keys = { "x-dpi", "y-dpi", "compression", "icc-profile", null };
- string[] values = { "%d".printf (dpi), "%d".printf (dpi), "8" /* Deflate compression */, icc_profile_data, null };
- if (icc_profile_data == null)
- keys[3] = null;
- writer.save (image, "tiff", keys, values);
- }
else
throw new FileError.INVAL ("Unknown file type: %s".printf (type));
}
=== modified file 'src/ui.vala'
--- src/ui.vala 2017-04-12 04:34:42 +0000
+++ src/ui.vala 2017-04-16 11:22:38 +0000
@@ -615,7 +615,7 @@
/* Check the file(s) don't already exist */
var files = new List<File> ();
var format = uri_to_format (uri);
- if (format == "jpeg" || format == "png" || format == "tiff")
+ if (format == "jpeg" || format == "png")
{
for (var j = 0; j < book.n_pages; j++)
files.append (book.make_indexed_file (uri, j));
@@ -663,12 +663,8 @@
var uri_lower = uri.down ();
if (uri_lower.has_suffix (".pdf"))
return "pdf";
- else if (uri_lower.has_suffix (".ps"))
- return "ps";
else if (uri_lower.has_suffix (".png"))
return "png";
- else if (uri_lower.has_suffix (".tif") || uri_lower.has_suffix (".tiff"))
- return "tiff";
else
return "jpeg";
}
@@ -1041,14 +1037,14 @@
private void show_page_cb (BookView view, Page page)
{
- var path = get_temporary_filename ("scanned-page", "tiff");
+ var path = get_temporary_filename ("scanned-page", "png");
if (path == null)
return;
var file = File.new_for_path (path);
try
{
- page.save ("tiff", quality, file);
+ page.save ("png", quality, file);
}
catch (Error e)
{
_______________________________________________
Mailing list: https://launchpad.net/~simple-scan-team
Post to : [email protected]
Unsubscribe : https://launchpad.net/~simple-scan-team
More help : https://help.launchpad.net/ListHelp