summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlessio Treglia <quadrispro@ubuntu.com>2010-04-22 14:59:03 +0200
committerAlessio Treglia <quadrispro@ubuntu.com>2010-04-22 14:59:03 +0200
commitdc950f77d2a9f9aa23f6bd0ea59648c34fff491b (patch)
tree7dd8578c488c19d710b30a416e3f3547534540b6 /src
parent279b3fab7a8fcee6ed831447b37e1ac5d0397d44 (diff)
Imported Upstream version 1.0.3upstream/1.0.3
Diffstat (limited to 'src')
-rw-r--r--src/book.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/book.c b/src/book.c
index 8493c84..0dce5f0 100644
--- a/src/book.c
+++ b/src/book.c
@@ -284,7 +284,7 @@ book_save_pdf_with_imagemagick (Book *book, GFile *file, GError **error)
for (iter = book->priv->pages; iter && result; iter = iter->next) {
Page *page = iter->data;
GFile *jpeg_file, *tiff_file;
- gchar *path;
+ gchar *path, *resolution_command, *stdout_text = NULL, *stderr_text = NULL;
gint jpeg_size, tiff_size;
jpeg_file = get_temporary_file ("simple-scan", "jpg");
@@ -302,6 +302,25 @@ book_save_pdf_with_imagemagick (Book *book, GFile *file, GError **error)
path = g_file_get_path (jpeg_file);
else
path = g_file_get_path (tiff_file);
+
+ resolution_command = g_strdup_printf ("convert %s -density %d %s", path, page_get_dpi (page), path);
+ result = g_spawn_command_line_sync (resolution_command, &stdout_text, &stderr_text, &exit_status, error);
+ if (result && exit_status != 0) {
+ g_warning ("ImageMagick returned error code %d, command line was: %s", exit_status, resolution_command);
+ g_warning ("stdout: %s", stdout_text);
+ g_warning ("stderr: %s", stderr_text);
+ result = FALSE;
+ g_set_error (error, BOOK_TYPE, 0,
+ "ImageMagick returned error code %d\n"
+ "\n"
+ "Command line: %s\n"
+ "Stdout: %s\n"
+ "Stderr: %s",
+ exit_status, resolution_command, stdout_text, stderr_text);
+ }
+ if (!result)
+ break;
+
g_string_append_printf (command_line, " %s", path);
g_free (path);
}
@@ -321,7 +340,13 @@ book_save_pdf_with_imagemagick (Book *book, GFile *file, GError **error)
g_warning ("stdout: %s", stdout_text);
g_warning ("stderr: %s", stderr_text);
result = FALSE;
- g_set_error (error, BOOK_TYPE, 0, "ImageMagick returned error code %d, command line was: %s", exit_status, command_line->str);
+ g_set_error (error, BOOK_TYPE, 0,
+ "ImageMagick returned error code %d\n"
+ "\n"
+ "Command line: %s\n"
+ "Stdout: %s\n"
+ "Stderr: %s",
+ exit_status, command_line->str, stdout_text, stderr_text);
}
g_free (stdout_text);
g_free (stderr_text);