annotating images, LaTeX and printer faults. ARGH!

Using Inkscape with other software? Talk about it here.
cjreeve
Posts: 7
Joined: Wed Jul 23, 2008 2:46 am

annotating images, LaTeX and printer faults. ARGH!

Postby cjreeve » Wed Jul 23, 2008 3:38 am

Hi,

Here is a common problem I come across when I try to annotate a pixelated image with non-pixelated characters.

I am writing a thesis using LaTeX. Including vector graphics (e.g. EPS files) work very well using the traditional way of compiling a LaTeX document into a PDF via the DVI and PS formats. If pixelated images are included I run into problems because EPS is a not compressed. However the PDF can still be created such that the EPS images are somehow compressed. This way I can import a JPEG into Inscape, annotate it and then save as an EPS file. The problem appears to be fixed until I try to print the document with a post script printer. When printing the EPS images are decompressed and the printer runs out of memory and freezes. Really it is a fault of the printer I think, but anyway, I want to be able to create a thesis people can print!

There is another way of creating PDFs with LaTeX. That is with pdfLaTeX where instead of including EPS images you can include JPEG, PNG and PDF images. Sounds promising? Printing a pixelated image this way works a dream because the printer can handle embedded JPEG and PNG files. EPS files can simply be embed in a PDF before including as an image in LaTeX. This is all done automatically with LyX (which I use to write my LaTeX) using the package ps2pdf .

However I have some pixelated images I want to annotate. Now I don't mind if my image is intermediate quality, but what I do want is that my labels and arrows are crisp clear. This is easy to do with PDFs and I used Inkscape to do this. I imported my JPEG or PNG, write on it and then save to PDF. When I compile my thesis the PDF and images look perfect. All seems ok until I try and print. The printer just spits out the following message: Error: undefinedresult. OFFENDING COMMAND: div ...

Basically the problem was with the PDFs I created with Inkscape.

To prove that it is theoretically possible to annotate a JPEG in a PDF and still get it to print I tried the following:
I create a PDF document with pdfLaTeX with an imbeded JPEG. I annotated the PDF with jarnal (http://www.dklevine.com/general/software/tc1000/jarnal.htm) and then printed my changes to PDF. Then I included this file in my thesis, cropping all the white space by trial and error. It worked!

Can anyone enlighten me what the problem is or have any suggestions as to a better way of doing this. I don't want to save my annotated files to a pixelated format.

I am using a mac os 10.4 and tried printing my PDFs vias Preview and Acrobat.

Cheers,

Chris.

User avatar
microUgly
Site Admin
Posts: 2985
Joined: Sat Jun 02, 2007 3:13 pm
Contact:

Re: annotating images, LaTeX and printer faults. ARGH!

Postby microUgly » Wed Jul 23, 2008 9:02 am

I'm not sure we have too many LaTeX users here. If you don't get a response you might like to try asking in a dedicated LaTeX community.

cjreeve
Posts: 7
Joined: Wed Jul 23, 2008 2:46 am

Re: annotating images, LaTeX and printer faults. ARGH!

Postby cjreeve » Thu Jul 24, 2008 11:33 pm

Actually I think it has nothing to do with LaTeX but with the pdf format. If I open the PDF of the picture with Preview or Adobe Reader it looks fine. However if I print-preview or save to ps it gets the bounding box wrong.

User avatar
versus
Posts: 7
Joined: Fri Jul 25, 2008 3:37 am

Re: annotating images, LaTeX and printer faults. ARGH!

Postby versus » Fri Jul 25, 2008 5:32 am

Hi,
microUgly wrote:I'm not sure we have too many LaTeX users here


I am a LaTeX user, and a new Inkscape user, as i needed a software to easily illustrate my scientific works. As a former Illustrator user, i found out that Inkscape suits my needs very well.

ps : if my english looks "weird", i am sorry : i am French :lol:

cjreeve
Posts: 7
Joined: Wed Jul 23, 2008 2:46 am

Re: annotating images, LaTeX and printer faults. ARGH!

Postby cjreeve » Fri Jul 25, 2008 7:23 am

Good on your for being a LaTeX user. :) I highly recommend LyX, which is a GUI for writing LaTeX in. It has all the functionality of LaTeX but looks nice to write in and has many short cuts so that you'll be able to write faster. It has many active (and many French) developers and in improving in leaps and bounds. It is just LyX more fun. :p

If you or anyone else is having problems with Inkscapes PDF files let me know if you have found away around it.

Cheers,
C

cjreeve
Posts: 7
Joined: Wed Jul 23, 2008 2:46 am

Re: annotating images, LaTeX and printer faults. ARGH!

Postby cjreeve » Fri Jul 25, 2008 7:36 am

I see I am not alone: https://bugs.launchpad.net/inkscape/+bug/172022

I'll investigate some of their suggestions. Maybe I need to learn how to use xfig after all...

C

User avatar
microUgly
Site Admin
Posts: 2985
Joined: Sat Jun 02, 2007 3:13 pm
Contact:

Re: annotating images, LaTeX and printer faults. ARGH!

Postby microUgly » Fri Jul 25, 2008 7:37 am

Like I said, i'm not a latex user so I can't follow your workflow. But I might be able to help extract some details.

So basically, you are doing the follow:
  1. Importing a bitmap into Inkscape
  2. Adding text to the bitmap
  3. Saving as EPS
  4. Importing the EPS into LaTex
  5. Saving the LaTex doc as PDF
  6. Opening the PDF (everything looks fine)
  7. Print the PDF and you get the error
Is this correct?

If you are using text in Inkscape I would recommend you convert your text to paths before saving as EPS. This will mean that you can't edit the text, but then EPS isn't an ideal format for editing anyway.

Also, if Latex can import PDF docs you might like try saving as that type from Inkscape instead.

cjreeve
Posts: 7
Joined: Wed Jul 23, 2008 2:46 am

Re: annotating images, LaTeX and printer faults. ARGH!

Postby cjreeve » Fri Jul 25, 2008 9:30 am

Almost, but not quite. The more complicated way was an attempted solution.

What I tried and didn't work:

1. Import a jpeg to inkscape, edit
2. Save file as pdf

It seemed there was something wrong with the pdf as I couldn't print it. I just had another play and I think I understand what was happening now. To reduce the quality of the jpeg, which was originally 2 MB, I just re-saved it to jpeg with high compression. The size after compression was about 120 kB I think. Then when I imported it to Inkscape (annotated it) and saved it to PDF it grew to 320 kB. (Any idea why it should increase in size so much?) Because I just compressed the picture to reduce the size, its actual dimensions were still a large 60 by 90 cm. I didn't realise this would be a problem, as being a scalable pdf I didn't mind about the actual dimensions. However if I convert the pdf to post-script the file size blows up to over 17 MB. This is what the printer was complaining about - it couldn't handle an image that big. If I reduce the actual dimensions of the picture and don't worry about compressing it so much and then export to pdf I guess that will work. I'll have to check tomorrow.

I guess this is not an Inkscape problem but a hazard of using rasterised images in post-script? Still, from 120 kB to 17 MB is a bit excessive!

User avatar
microUgly
Site Admin
Posts: 2985
Joined: Sat Jun 02, 2007 3:13 pm
Contact:

Re: annotating images, LaTeX and printer faults. ARGH!

Postby microUgly » Fri Jul 25, 2008 9:49 am

When it comes to saving as PDF with a bitmap image, I don't know what happens. It's possible that whilst the bitmap may have been JPG, in the process of saving as PDF it's converted to PNG which would make it larger. You could check this yourself by opening the PDF in Inkscape and viewing the XML to see what the image is named.

60cm by 90cm doesn't actually tell us how big the file is without the DPI. It could 6 x 9 pixels and still be 60cm by 90cm when printed :) But if we assume the resolution is about 100dpi we might be talking about an image that is 2300 x 2500 pixels. Now, I believe PS is a really really old standard and I doubt that it supports any compressed bitmap formats such as PNG or JPG. So your 2300 x 2500 bitmap is probably being converted to an uncompressed TIFF format. 2300 x 2500 pixels where 24bits is used for each pixel we get an filesize of over 16MB. This is most likely why your PS is so much larger than your PDF.

User avatar
versus
Posts: 7
Joined: Fri Jul 25, 2008 3:37 am

Re: annotating images, LaTeX and printer faults. ARGH!

Postby versus » Fri Jul 25, 2008 10:55 am

cjreeve wrote:The size after compression was about 120 kB I think. Then when I imported it to Inkscape (annotated it) and saved it to PDF it grew to 320 kB. (Any idea why it should increase in size so much?) Because I just compressed the picture to reduce the size, its actual dimensions were still a large 60 by 90 cm. I didn't realise this would be a problem, as being a scalable pdf I didn't mind about the actual dimensions.


Why don't you just import the pdf file in the LaTeX file with :
\includegraphics[scale=1]{mydoc.pdf}
and compile with pdflatex instead of latex. That's what i always do and i never have to save in eps format. Never had a problem !
If i remember well, you can include LaTeX code in a LyX document.

cjreeve
Posts: 7
Joined: Wed Jul 23, 2008 2:46 am

Re: annotating images, LaTeX and printer faults. ARGH!

Postby cjreeve » Fri Jul 25, 2008 7:59 pm

Yes, that is what I do.

Sorry I am not clear.

I compile my Inskacape pdf into my main pdf document with pdflatex. That works fine until I try and print. It is at this point that the pdf gets turned into post script. The embedded pdf image in the pdf blows up to 17 MB file, which the printer can't handle.

I think maybe the printer driver, or whatever converts it to post script, can't figure out the Inkscape pdf so that it rasterises it to fine detail and then turns it into a post-script.

Chris.

cjreeve
Posts: 7
Joined: Wed Jul 23, 2008 2:46 am

Re: annotating images, LaTeX and printer faults. ARGH!

Postby cjreeve » Fri Jul 25, 2008 8:15 pm

microUgly wrote: But if we assume the resolution is about 100dpi we might be talking about an image that is 2300 x 2500 pixels. Now, I believe PS is a really really old standard and I doubt that it supports any compressed bitmap formats such as PNG or JPG. So your 2300 x 2500 bitmap is probably being converted to an uncompressed TIFF format. 2300 x 2500 pixels where 24bits is used for each pixel we get an filesize of over 16MB. This is most likely why your PS is so much larger than your PDF.


Yes I just checked, and the original file was about 2000 x 3000 pixels. However if I open the pdf image again with Inkscape it says the image width is 1 pixel by 1 pixel???

I'll try and familiarise myself with the XML editor.

Cheers,

Chris.

AJ Blackman

Re: annotating images, LaTeX and printer faults. ARGH!

Postby AJ Blackman » Thu Jul 31, 2008 5:50 am

You might want to change the printer settings on the PC.
I am not a LaTex user. I came across the same error in a Windows 2003 server networking environment. We have two servers talking to a 3rd server which controls our network printing que. One server printed to our color printer just fine. Print jobs came out with the banner page and document. The second server's print jobs came out with 2 banner pages, a blank page, and a page with the "Error: Undefinedresult...." on it. I used the following solution:

Log on to PC as administrator.

Go to Start> Printers & Faxes.

Right-click the color printer and select Properties.

Go to the Advanced tab and click Printing Defaults.

Go to the Tek Color tab and change the settings from “Automatic” to “Use Printer Control Panel Setting”

This resolution is different for different systems, but might lead your in the right direction. It eliminated the error and stopped the 2nd banner page from printing on our system.


Return to “Inkscape & other”