3

I am converting images to EPS files with the following script.

%% Image 2 eps file.
% - img: the image.
% - eps: eps filename.
function Image2Eps(img, eps)
    imshow(img,'border','tight','InitialMagnification',100);
    print(gcf,'-depsc',eps);
end

The file generated almost bound the image tightly. But a small margin is always left on the top and on the right side. How to make the EPS file exactly the size of the bitmap image?

Charles
  • 50,943
  • 13
  • 104
  • 142
Richard Dong
  • 704
  • 1
  • 7
  • 13
  • 2
    why are you using Matlab for this task? why not using `gs`? – Shai Dec 31 '12 at 10:38
  • 1
    This is the relevant comment in the documentation, perhaps it helps: `Note: There can still be a border if the image is very small, or if there are other objects besides the image and its axes in the figure.` Besides preventing it from happening you may be able to remove the border afterwards? – Dennis Jaheruddin Dec 31 '12 at 13:36
  • Shai: can you give some further ideas about converting bitmap images to eps with ghostscript? A command line for demonstration? – Richard Dong Jan 01 '13 at 09:59

1 Answers1

0

If you are not too locked on Matlab. You can use Image Magick to do the conversion. I used it in a command line:

imgtops2.exe imge.ppm -e -c 0,0 -o image.eps

I used it on a Windows machine, but I believe they have working binaries for other OS as well.

Furthermore, once you have a working command line in dos or shell you can call it from Matlab using system, dos or unix commands.

PS.

I used an old version of ImageMagick, in more recent releases they might have changed imgtops2 to convert, you'll have to look at their documentation.

Shai
  • 111,146
  • 38
  • 238
  • 371