Merge lp:~soliloque/simple-scan/remove_ps_tiff into lp:~simple-scan-team/simple-scan/trunk

Proposed by soliloque
Status: Merged
Merged at revision: 964
Proposed branch: lp:~soliloque/simple-scan/remove_ps_tiff
Merge into: lp:~simple-scan-team/simple-scan/trunk
Diff against target: 113 lines (+3/-47)
3 files modified
src/book.vala (+0/-32)
src/page.vala (+0/-8)
src/ui.vala (+3/-7)
To merge this branch: bzr merge lp:~soliloque/simple-scan/remove_ps_tiff
Reviewer Review Type Date Requested Status
Robert Ancell Approve
Review via email: mp+322607@code.launchpad.net

Commit message

Remove code for ps and tiff support

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :

I like less code. :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/book.vala'
2--- src/book.vala 2017-03-29 09:40:01 +0000
3+++ src/book.vala 2017-04-16 11:22:38 +0000
4@@ -165,34 +165,6 @@
5 }
6 }
7
8- private void save_ps_pdf_surface (Cairo.Surface surface, Gdk.Pixbuf image, double dpi)
9- {
10- var context = new Cairo.Context (surface);
11- context.scale (72.0 / dpi, 72.0 / dpi);
12- Gdk.cairo_set_source_pixbuf (context, image, 0, 0);
13- context.get_source ().set_filter (Cairo.Filter.BEST);
14- context.paint ();
15- }
16-
17- private void save_ps (File file) throws Error
18- {
19- var stream = file.replace (null, false, FileCreateFlags.NONE, null);
20- var writer = new PsWriter (stream);
21- var surface = writer.surface;
22-
23- for (var i = 0; i < n_pages; i++)
24- {
25- var page = get_page (i);
26- var image = page.get_image (true);
27- var width = image.width * 72.0 / page.dpi;
28- var height = image.height * 72.0 / page.dpi;
29- surface.set_size (width, height);
30- save_ps_pdf_surface (surface, image, page.dpi);
31- surface.show_page ();
32- saving (i);
33- }
34- }
35-
36 private uint8[]? compress_zlib (uint8[] data)
37 {
38 var stream = ZLib.DeflateStream (ZLib.Level.BEST_COMPRESSION);
39@@ -598,12 +570,8 @@
40 {
41 case "jpeg":
42 case "png":
43- case "tiff":
44 save_multi_file (type, quality, file);
45 break;
46- case "ps":
47- save_ps (file);
48- break;
49 case "pdf":
50 save_pdf (file, quality);
51 break;
52
53=== modified file 'src/page.vala'
54--- src/page.vala 2015-09-13 21:35:37 +0000
55+++ src/page.vala 2017-04-16 11:22:38 +0000
56@@ -676,14 +676,6 @@
57 keys[2] = null;
58 writer.save (image, "png", keys, values);
59 }
60- else if (strcmp (type, "tiff") == 0)
61- {
62- string[] keys = { "x-dpi", "y-dpi", "compression", "icc-profile", null };
63- string[] values = { "%d".printf (dpi), "%d".printf (dpi), "8" /* Deflate compression */, icc_profile_data, null };
64- if (icc_profile_data == null)
65- keys[3] = null;
66- writer.save (image, "tiff", keys, values);
67- }
68 else
69 throw new FileError.INVAL ("Unknown file type: %s".printf (type));
70 }
71
72=== modified file 'src/ui.vala'
73--- src/ui.vala 2017-04-12 04:34:42 +0000
74+++ src/ui.vala 2017-04-16 11:22:38 +0000
75@@ -615,7 +615,7 @@
76 /* Check the file(s) don't already exist */
77 var files = new List<File> ();
78 var format = uri_to_format (uri);
79- if (format == "jpeg" || format == "png" || format == "tiff")
80+ if (format == "jpeg" || format == "png")
81 {
82 for (var j = 0; j < book.n_pages; j++)
83 files.append (book.make_indexed_file (uri, j));
84@@ -663,12 +663,8 @@
85 var uri_lower = uri.down ();
86 if (uri_lower.has_suffix (".pdf"))
87 return "pdf";
88- else if (uri_lower.has_suffix (".ps"))
89- return "ps";
90 else if (uri_lower.has_suffix (".png"))
91 return "png";
92- else if (uri_lower.has_suffix (".tif") || uri_lower.has_suffix (".tiff"))
93- return "tiff";
94 else
95 return "jpeg";
96 }
97@@ -1041,14 +1037,14 @@
98
99 private void show_page_cb (BookView view, Page page)
100 {
101- var path = get_temporary_filename ("scanned-page", "tiff");
102+ var path = get_temporary_filename ("scanned-page", "png");
103 if (path == null)
104 return;
105 var file = File.new_for_path (path);
106
107 try
108 {
109- page.save ("tiff", quality, file);
110+ page.save ("png", quality, file);
111 }
112 catch (Error e)
113 {

Subscribers

People subscribed via source and target branches