I have an raster image like this. That I would like to convert into an svg. enter image description here

I tried the Image Trace option in Illustrator thinking that it would makes colored squares on top of a black box but that does not work and just turns the whole image into a black shape.

I need it to convert into a vector because it turns into this when embedded into a pdf. enter image description here

I'm open to any solution other than converting it to a vector if it makes it look like the first picture inside a pdf. The pdf was generated using Latex if that information helps. The original image is here if required.


3 Answers 3


I would try the following image trace options. You want to make sure your corners are set to 100%. The end result is about 41kb SVG.

image trace options

I think it turns out pretty good.


Demo zoom in

You could also try Object -> Create Object Mosaic. You will have to mess around with the amount of tiles you use.

  • 1
    Create Object Mosaic worked perfectly for me. I couldn't get the image trace to work with the parameters as you showed. My image just turns into a black shape. Video is here if you want to take a look.
    – Rashiq
    Apr 7, 2021 at 15:29

Personally I think tracing this image as vector graphic is a bit overkill.

If converted to a png file with a reasonable resolution (quick way: just take a screenshot of the zoomed in tiff image):

enter image description here

your pdf reader should not have problems displaying the image:

enter image description here

(including it as image will avoid all problems with all these "thin line enhancements" features etc. most pdf viewers have switched on by default)


Seemingly you have already tried to make a SVG file by tracing the image in Inkscape, but with no success.

A fix: Your 100 x 100 pixels image should be scaled to bigger size to make Inkscape believe the dots are rectangles. Scaling it in Photoshop or GIMP to 1000 x 1000 pixels with the "nearest neighbour" resampling does the job. Rectangles get scaled perfectly with no blur.

The tracing result looks perfect:

enter image description here

After ungrouping the black part should be deleted because it's full of holes. It must be replaced by a solid black background shape. Here the traced black part is moved aside:

enter image description here

Delete it after the new one is drawn and placed. Otherwise you would have no way to place the new one exactly.

But why it should be replaced?

Answer: The edges of the holes fit exactly. SVG:s are often rendered so that edges have 1 px wide transparent zone for anti-aliasing. White could be seen through that gap. A solid background shape stops it.

BTW. There's another answer which essentially suggest you to use the scaled bitmap image as is. Not bad, if there's no other reasons to have a vector than make it look sharp.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.