pixel to vector

edited November 2015 in How To...

I need to change this .jpg to some vector-format:

it consists of 2x2 px, which are black or white. I need to convert thousands of these .jpg - all same format. 280x52px

any idea?

Tagged:

Answers

  • By vector format do you mean vector-graphics format like SVG? If so I can't see any benefit.

    You could encode it instead, you could store the image in 455 bytes.

  • beginRecord() in the reference will let you record a svg or PDF. Just iterate over the pixels and add a rect if the pixel is black.

  • Like @quark I'd question why @dumbIdiot wants this: in terms of file size the vector format would be larger. Perhaps the reason for the requirement could lead to a more useful answer ;)

  • thx for your answers. I am better in coding, than with graphicformats. I need to send these graphics to a printery. I thought svg would be better suited for scalability, but that's probably BS. Does it make a difference, when there's a font included? the format on acrylic glass will only be ~60x10mm for this picture and has to be printed with the highest possible resolution.

    I don't know what the printing machine exactly does with the picture. I mean it has to somehow translate a pixelformat do it's DPI resolution!?

    Now I talked to a printery and they suggest sending TIFs.. Maybe someone can enlighten me on formats, scalability and things. I thought by using a vectorformat all possible problems would be excluded.

  • would it be useful, if I generate above picture in a much higher resolution? lets say instead of 2x2px for a square I could use 16x16px? But in SVG it should be the same, I guess?

  • As an aside, jpg probably isn't the best format to store something with such high contrast as it's lossy and you end up with pixels that are neither black nor white. Gif or PNG would be better.

  • @koogs - I'd assume @dumbIdiot doesn't control the output format. Looking at the jpeg however it looks completely free of compression artefacts. That means it should be possible to increase the size to whatever is required by a printer in an image editor: the trick is to tun off any kind of interpolation. I don't have any suitable graphics package on this PC; but if IIRC in Photoshop you select 'nearest neighbour' or some-such. I can confirm later today :)

  • I will honestly tell you what I did (so you have something to laugh):

    My javascript code choses in some way from 4 different 4x4px GIFs and lines them up in the format 70x13. So the browser displays 910 GIFs. I grabbed this with gadwin printscreen, which stores it as PNG. I opened the PNG with gimp to be able to add something (not part of above image) and saved it as JPG. Meanwhile I converted the JPG with inkscape to SVG, because I thought it would be useful. Now the printery demands TIF and I let some online tool convert the SVG to TIF.

    Unfortunately I don't know how to generate 1 image with javascript instead of 910 in the proper format, so I seem to be forced to use a screengrabber.

  • edited November 2015

    it sounds like there's more to it than just the b&w pixels but...

    1188 pixel_to_vektor.gif
    9493 pixel_to_vektor.jpg
    1153 pixel_to_vektor.png
    

    (size in bytes)

    I let some online tool convert the SVG to TIF.

    saveFrame can save images as tif, in fact it's the default. so if you can generate the entire image using processing then you can produce tifs easily

    (but beware because tif is such a huge standard that it might not be what you want)

  • actually, if you convert to indexed palette (2 colours) before saving you can get the png down to 493 bytes.

  • @dumbIdiot: Working on the assumption that you can't go back and generate the images again, then my earlier suggestion definitely works. You can increase the size of your sample image to print resolution with no loss of quality (by disabling any resampling option) in a half decent graphics package.

    Increasing image size is usually a lossy operation though: so the same might not apply to any other elements you added to your images...

    I tested in both Photoshop and IrfanView, both of which can do batch jobs.

Sign In or Register to comment.