Best way to mix vectors and rasters? (solved)

General discussions about Inkscape.
User avatar
ianp5a
Posts: 106
Joined: Thu Sep 02, 2010 1:30 am

Best way to mix vectors and rasters? (solved)

Postby ianp5a » Tue Feb 04, 2014 5:32 am

I am modifying raster images from my camera using Gimp where I need few vectors. However some of my images are vector heavy. Most of the content is vector objects on several layers. The raster may be part of the background with a mix of raster and vector objects in front. I want to find the best way to modify this artwork without losing the raster quality by re-rendering it. Is it:
Create vector shapes and load them into Gimp?
- The raster is not re-rendered. Image quality remains unaffected. But I cant edit the vectors. Or can I?
Copy the Raster images as objects in inkscape.
- How do I lock them so pixels are exported 1:1 rather than being re-rendered?
- Here is an example that is largely vector shapes. Composed in Inkscape, just the sky and ground is raster.
Image

What do people do?
Last edited by ianp5a on Thu Feb 06, 2014 4:35 am, edited 1 time in total.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Best way to mix vectors and rasters?

Postby Lazur » Tue Feb 04, 2014 9:38 am

Hi.

Looking at your image I would use gimp.


What this is going to be displayed? Large format print or screen?
Either way, the raster part limits the size to some point to avoid pixelation.
Thus you won't need your vector based drawing elements as vectors in the image.
Gimp actually can load svg paths in a way -you can turn them to be selections, or draw with a tool along them.
You can edit them there as well, with less options than in inkscape.
After that, you would need to turn them to selections, and colourise the parts -possibly by turning the selected ara to be a layer mask.
Not a quick way to edit paths and colour them repeatedly.


To export raster images from inkscape avoiding the rendering's anti-aliasing, you would need to match the image's pixel grid with the export area's pixel grid.
For example the embedded image is at (0;0), being 1920/1080 pixels, then the export area would be good anywhere with even dimensions, like at (100;100), being 640/480, and, giving a resolution for the export 90 dpi.
That would work with no blurring.
You can import the raster parts, but cannot edit them there, like that tiled texture on the ground.

User avatar
ianp5a
Posts: 106
Joined: Thu Sep 02, 2010 1:30 am

Re: Best way to mix vectors and rasters?

Postby ianp5a » Tue Feb 04, 2014 7:32 pm

Thanks for your answers
>What this is going to be displayed? Large format print or screen? Both. I'm trying to find a general principle for future images.
>Use Gimp: Vectors-to-paths/selection. Sounds like a lot of work or lost work when it gets complex. (Z-order and inkscape shading.)
>Use Gimp: Rasterise Vectors: I'd guess make several separate renders to cope with z-order. But transparent vector shapes would not work.

> export raster images from inkscape avoiding the rendering's anti-aliasing,
Thanks "image properties" has size and position. Is "position" a pixel value the same as the raster grid? If so, adding up the top left and bottom right raster would give me the output size. However I'm not sure how this position relates to the raster grid size.
I see this might be covered by : viewtopic.php?f=5&t=12924 or viewtopic.php?f=5&t=11864

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Best way to mix vectors and rasters?

Postby Lazur » Tue Feb 04, 2014 11:15 pm

The position coordinates of the export area are showing the bottom left and top right coordinates of the rectangular area, thus the area size is (x1-x0)/(y1-y0).
If you export it at 90 dpi, you will get a raster image that has it's size exactly as inkscape shows at 100% zooming.

Making it simple: if you have a raster image in your drawing,
if you are not scaling it up, leaving it at it's original size,
and set the export area around that image -with the selection area option-,
and use 90 dpi, you won't have any blurring.
Even though for practical reasons the image is better kept at even pixel positions,
so that pixel fitted nodes of paths with straight horizontal/vertical lines would look as sharp as possible too on the exported png.

User avatar
ianp5a
Posts: 106
Joined: Thu Sep 02, 2010 1:30 am

Re: Best way to mix vectors and rasters?

Postby ianp5a » Wed Feb 05, 2014 4:45 am

Thanks but:
I dragged a 3457x4608 pixel JPEG into a new Inkscape drawing.
I left it at the size it appeared.
Export PNG at 90 dpi (Selection) shows an output size of 711x948 px
Export PNG at 437.50dpi (Selection) shows an output size of 3457x4608 px (as the original)

The exported PNGs were exactly those sizes. The 437.5 dpi exported PNG appeared to be un-blurred!

So I could actually use the magic 437.50dpi and not stretch it in any way on the sheet. This could be my solution.

Another test:
I dragged a 600x400 pixel PNG into a new Inkscape drawing. (as JPG too)
I left it at the size it appeared. Which was nearly as big as the high res test above. Despite it being very small!! This is a clue!
Export PNG at 90 dpi (Selection) shows an output size of 750x500 px
Export PNG at 72dpi (Selection) shows an output size of the original
Last edited by ianp5a on Wed Feb 05, 2014 5:18 am, edited 2 times in total.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Best way to mix vectors and rasters?

Postby Lazur » Wed Feb 05, 2014 5:11 am

What do you mean by dragged -did you import it?
There is an indication line at the bottom, showing the exact pixel sizes of the raster images.
If they don't mach with the dimension values at the top, they are scaled.

I'm guessing your second embedded jpeg had a 72 dpi set in it's codes?
Last edited by Lazur URH on Wed Feb 05, 2014 5:16 am, edited 1 time in total.

User avatar
ianp5a
Posts: 106
Joined: Thu Sep 02, 2010 1:30 am

Re: Best way to mix vectors and rasters?

Postby ianp5a » Wed Feb 05, 2014 5:15 am

Yes. I initially dragged it in from the file manager. Now I've just verified it using File - Import with all the same results.

Checking the status line at the bottom shows the correct pixel size on both the large and the small JPG. Even though they appear nearly the same size. Although stretching them with the handles did not change the stated pixel dimensions.

I couldnt find any dpi in the exif from either picture. The large one came from a camera. The small one was a gimp export.
I repeated a gimp export at 1200x400 and 1200x800 and got the same 72dpi.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Best way to mix vectors and rasters?

Postby Lazur » Wed Feb 05, 2014 10:17 am

Then I'm not sure how the gimp's or your camera's dpi setting works -there is an option in gimp with the export as png to save the image's resolution or not.
So after importing the raster images in inkscape, scale up them by typing the correct dimensions in the top boxes -the values that are displayed at the bottom.
Then a 90 dpi export should do it.

User avatar
ianp5a
Posts: 106
Joined: Thu Sep 02, 2010 1:30 am

Re: Best way to mix vectors and rasters? SOLUTION

Postby ianp5a » Thu Feb 06, 2014 12:21 am

How do you mean scale them with dimensions?
The Transform Scale command has relative values and with Export PNG, entering the correct dimensions give the 437.50 dpi result.
Try it yourself with pictures from a digital camera and see what the resulting dpi value is.

Anyway. I'm now happy with my original question. I import a picture. Draw vectors on top of it. Arrange the drawing exactly as I want in a much better way than in Gimp. Then export at the dpi that gives the picture its original dimensions. Even if it is clipped. If I add other bitmaps and stretch them I expect them to be re-rendered. I'll know the un-stretched images from the same source will not be degraded.
1) Import image
2) Select it
3) Start Export PNG
4) Choose "Selection"
5) Enter the images original pixel dimensions
6) Note the DPI value and save it. (edit the filename perhaps)
Last edited by ianp5a on Thu Feb 06, 2014 5:42 am, edited 1 time in total.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Best way to mix vectors and rasters?

Postby Lazur » Thu Feb 06, 2014 12:40 am

I'm trying to reproduce it yet with no luck.
By importing or opening an image, the size is automatically scaled to the pixel size at the indication line.
And by that, each of the image's pixels is at an even pixel of the coordinate system being used, thus it has to be all good at 90 dpi.
I'm confused what's going on.

You mentioned you can only scale by % values -that unit is written in a dropdown box at the top, where you can set pixels as well.

User avatar
ianp5a
Posts: 106
Joined: Thu Sep 02, 2010 1:30 am

Re: Best way to mix vectors and rasters?

Postby ianp5a » Thu Feb 06, 2014 1:03 am

Oh I see. The H and V size at the top not the Transform command. H and V defaults to the correct pixel dimensions.
I'm using the Linux (Kubuntu KDE) version of 0.48 if that makes a difference.

I just installed 0.48.4 on a Windows PC and it gets the 90 dpi. Although I dont have accesss to the same images. I'll test further when I get home.
Last edited by ianp5a on Thu Feb 06, 2014 1:24 am, edited 4 times in total.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Best way to mix vectors and rasters?

Postby Lazur » Thu Feb 06, 2014 1:19 am

I'm using opensuse's version.

User avatar
ianp5a
Posts: 106
Joined: Thu Sep 02, 2010 1:30 am

Re: Best way to mix vectors and rasters?

Postby ianp5a » Thu Feb 06, 2014 4:14 am

I've now tried jpegs from various cameras and scanners and get the right pixel dimensions at 72, 90, 225, 375, 400, 437 dpi depending on the source.

I've now found the values in the EXIF data. If I remove all EXIF data, the image needs 90 dpi to scale right. Mystery solved.


Return to “General Discussions”