'microsoft print to pdf' makes pdf image no clear - pdf

I print qr.bmp into qr.pdf with 'microsoft print to pdf'.
Original qr.bmp is pure black (RGB 0,0,0), and perfect clear.
But qr.pdf is vague, not clear.
how to get clear image from pdf (or microsoft print to pdf)?
qr.bmp
zoomed qr.pdf
//////////////////////////////////////////////////////////////
I have tried to get pdf from printing job with ghoststcript, and also unclear pdf qr image, but improved pdf.
With -dGraphicsAlphaBits=1, I got more clear image, but not clear.
Can I get clear image from ghostscript?
gswin32c.exe -q -dBATCH -dNOPAUSE -dGraphicsAlphaBits=1 -sDEVICE=pdfwrite -sOutputFile=qr.pdf -

It is not always obvious if a source QRcode is good for primary use here are two good ones they can be reduced small without problems, scan to see at what distance they work.
        
Your camera autofocus should jump to the upper pair equally but struggle with focusing on the worst lower left one.
these two suffer some damage during reduction it may not be instantly obvious and they should still function, but perhaps at closer range.
        
What makes a good QRcode source ? is a good generator and here 4 different online FREE generators produce very different results and qualities when re scaling.
It is important you test the generator output by reducing the number of pixels in monochrome GIF or TIF or PNG formats as Black and white (should not be grey, except for rotation) nor castellated as seen in the lower left image. Also every black or white block should be truly square and equal the lower right is not even.
Your first image already shows that problem as the blocks are not even (you have 5s and 4s) and as soon as they are rescaled they will start causing issues in quality reading.
When you inject 1:1 or 2:1 (preferred) or print as PDF (not auto unless tested for scales), it is important that scaling is calculated to preserve monochrome squares, without degrading. Jpeg format or colour is NOT suitable for QRcodes (especially bulk processes) , unless quality assurance inspected for tolerance problems.
Your question says can GhostScript out put a crisp image and the answer is yes if the input is good and crisp as it cant correct for bad sources so here squares of one single pixel are output 100 times larger without any aberrations whatsoever
Source Probably too small to be detected until enlarged.
enlarged in PDF note the pixels are single pixels (no noise or chatter)
gswin32c -dGraphicsAlphaBits=1 -sDEVICE=pdfwrite -o qr.pdf -f in.pdf
Output (qr.pdf) copy and pasted in paint for checking. Quality in Quality out = 100% fidelity each block is exactly 100 x 100 pixels e.g. 10,000 times better! No sign of a failure.

Related

Why is the pure Cyan image in this PDF not displayed as pure Cyan?

Can anyone tell why the image in this pdf does not display as 100% Cyan?
clrtestc - NOPREBLEND32.PDF
Warning: I probably know just enough about pdf and colour to be dangerous!
I'm pretty sure each colour plane of the image is in a separate image. Here's a blended version if that helps.
I know the ColorSpace is DeviceCMYK
I'm pretty sure there is only 100% Cyan in the image, at least there was when it went into the PDF converter.
What went in:
CMYK: 100,0,0,0
RGB: 0,255,255
What I measure coming out:
CMYK: 100,27,0,6
RGB: 0,173,238
I'm foxed! Is there some filter affecting the rendering of the PDF?
There's also Magenta, Yellow and Black versions if they help.
Any help much appreciated.
The PDF file is extraordinarily complicated, it has numerous Forms, some of them nested, most of which are empty. However there only appears to be one image, which is defined in an Indexed CMYK space. So as far as I can see, this is indeed a 100% cyan image.
The extended graphics state does use the Multiply Blend mode, and there is no group and no page group specified, so the colour space used for the blending will depend on the colour model of the output device. If that's a monitor, then it's entirely possible that the resulting output will be RGB.
That's because your CMYK image needs to be converted to RGB in order to be blended using that colour space.
Incidentally, the image is in an Indexed colour space. In your image all the image samples have the same value, that value is then consulted in a lookup table, and that table returns the CMYK components. So no, there is not one image per colour plane, or at least, not in this file.
To be honest, you're going to have to explain better how you are evaluating the content of the PDF file. As far as I can see the image is 100% cyan, and when rendered to a CMYK device, it will remain 100% cyan. If you render to an RGB device, it will be converted to RGB. A poor quality PDF consumer might decide to convert to RGB in the absence of a defined colour space for the blending operation.
Since the blending mode doesn't actually do anything (there's no defined alpha, SMask or any other transparency in the file) you could remove that and see if it sorts out your problem.
Edit
Your screen will be an RGB device, so no matter what the CMYK values in the PDF file are, there won't be any CMYK in the screenshot. The PDF rendering engine will have to convert the CMYK to RGB.
So the PDF rendering engine performs an opaque CMYK->RGB conversion. Then you take a picture of that RGB screen. You load that into an image editing application, and ask it what the RGB values are and presumably what it thinks are the CMYK equivalents.
If the CMYK->RGB calculation that the PDF viewer performs is not the inverse of the calculation that the RGB->CMYK image application performs, then you won't be getting the right values!
There's no way to predict what the RGB intermediate values 'should' be, because there is no 'right' answer here. Fundamentally this isn't a reliable technique for evaluating the colour.
It's hard to make any kind of recommendation without knowing what you are trying to achieve (and possibly why), and what tools you are prepared to use. I believe Acrobat Pro would allow you to look at the colour values directly for example. Or you could use something like Ghostscript to create a CMYK TIFF file, then open that in an image application which supports CMYK (like Photoshop) and look at the values there.
But rendering to the screen, taking a screenshot and trying to figure out what the CMYK values might or might not have been is not really going to work.

Generate isometric tiles from flat textures

Is there a simple tool (or code) to generate isometric tiles (cubes format) from using 1 or 2 (side/top) textures:
For example taking Minecraft grass top and side texture:
And generating a isometric result as:
I have a folder containing all blocks textures (top and side if needed, blocks can be top/side identicals)
I want to iterate and generate all isometrics blocks from this input, saving them as .png files, but I don't know how to join textures and generate this.
Is there an existing software, api, cli tool that I would be able to call from my iteration script ?
For a simple 3D cube like this, you can follow the ImageMagick documentation:
convert \
\( tile_top.png -alpha set -virtual-pixel transparent \
+distort Affine '0,512 0,0 0,0 -87,-50 512,512 87,-50' \) \
\( tile_left.png -alpha set -virtual-pixel transparent \
+distort Affine '512,0 0,0 0,0 -87,-50 512,512 0,100' \) \
\( tile_right.jpg -alpha set -virtual-pixel transparent \
+distort Affine ' 0,0 0,0 0,320 0,100 320,0 87,-50' \) \
\
-background none -compose plus -layers merge +repage \
-compose over isometric_cube.png
If you don't care if your source image turns into a blurry mess, then sure, use whatever 2d scaling/transform method you want. Try rotating a low res texture a non-multiple-of-90 degrees and see what happens -- it's ugly.
If you want the result to look pixel perfect, then you need to use a (decent enough) 3d renderer for the projection -- and disable antialiasing.
I'm willing to bet Blender could do it and that would be free, although I haven't tried doing it in Blender. There's probably a way to do it any 3d renderer that lets you adjust a camera completely.
You put the source square texture on a square flat 2d surface, then render it with a created camera set to orthographic (not perspective) and angled appropriately -- in your case, since the tiles look dimetric to me, rotated to either side 45 degrees and also 30 degrees down. That'll give you a pixel perfect render that you can just save to file or copy to clipboard for editing in whatever image software you want -- you'll still need to add an alpha channel to it, for example.
If you get the camera angles right, you just need to play with the camera distance a bit to get your source object+texture to fit in the render window, and the height to center it -- but it's not a lengthy or difficult process since you already know what size you want it to be and centering isn't hard either. Even with the distance too far, it'll still look mostly right -- just too small. So then you simply move the camera closer to the target object (in local coordinates so the angles don't change) and re-render and repeat as necessary. You only have to do this step once by hand, after that you load the saved scene in Blender/3ds Max/Maya/Whatever and swap the texture.
Here's a good online tutorial for doing exactly what you want in 3dsmax, but again I think it would pretty much work in any actual 3d renderer that gives you complete control over the camera:
http://www.pixelpilot.dk/isometric.htm
Note that if your tile has height above the 0 plane (your example does), then you'd have to take that into account -- might want to start with something simpler and get that working and understand it first before tackling height.
This really truly is the only way to do it right and get consistently good results. The only alternatives are: a) be a gifted artist and just hand draw your sprites b) have sprites so low in resolution that it doesn't require any noteworthy level of skill.
Otherwise, like the rest of us, you model it in 3d first and then render it to get a projection, then touching it up in an image editor by hand after the heavy lifting is done.
Hope that helps.

How to cut the png image as per the shape?

I have no experience on any image processing/editing tool. And I am doing a project, which requires me to use different shapes. I could create different shapes using visio. But however not able to get rid of white background behind. I need only shape not squared white background.Tried online out of my ways but not successfull.
Any help will be greatly appreciated.
Thanks,
Ganesh
Absolutely any image file has to be contained within a rectangular frame, this includes png and SVG.
Some image file formats can have what are called alpha channel backgrounds this allows you to see through transparent areas.
What you want to do is remove the white background to expose the alpha channel background in Photoshop (or similar tool) which can then be saved out as transparent.
For example in Photoshop:
If you open this image directly and have no other layers, double click the layer that says background and OK the confirmation box. This turns your flat image into a layered image
Select the magic wand tool and ensure you have a high tolerance set (3)
with the wand selected click the white area to bring up a marquee around your selection (the white background) and hit delete to remove it.
Your image should now have a chequered background which is the transparency showing through.
If you now go to file > save as and select png, your image should now be saved out with an alpha background.
Please note: There are further optimisations to make if this is for web, including file formats and file size but that is beyond the scope of this question but I encourage you to read up on the Gif format and it's restrictions, the difference between 8bit and 24bit pngs and how to use SVG.
You can do it pretty simply at the command-line using ImageMagick which is free and installed on most Linux distros and is available for OSX and Windows.
Basically, you want to make your whites transparent, so you would do
convert shape.png -transparent white result.png
If your whites are a little bit off-white, you could allow for some variation with a little fuzz as follows:
convert shape.png -fuzz 10% -transparent white result.png
I added the checkerboard background just so you can see it on StackOverflow's white background - it is not really there.
By the way, you may like to trim to the smallest bounding rectangle while you are there:
convert shape.png -fuzz 10% -transparent white -trim result.png
By the way, you can also draw your shapes with ImageMagick:
convert -size 150x150 xc: -fill none -stroke "rgb(74,135,203)" -draw 'stroke-width 90 ellipse 0,0 80,80 30,80' arc.png
See Anthony Thyssen's excellent examples here.

Margins Disappear In PDF -> PNG Conversion with ImageMagick

I'm having troubles with converting PDF to PNG in ImageMagick. I've used different variations, including using Ghostscript and piping the output to ImageMagic (as given here - which doesn't seem to work for me, so I have to save to a temp file instead of using a pipe). I've found this is working best for me:
convert -background transparent -density 150x150 Test.pdf Test-IMSoloOut.png
Here's a screenshot of the original PDF in my viewer (Preview, on OS X):
And when I convert it, I get this:
The problem is it's dropping the margins. I'm not clear whether it's making them transparent or what, but the formatting of the image looks sloppy without the margins.
I was given this to try:
convert -density 150x150 Test.pdf -gravity center -background transparent -extent 612x792 Test-Extras.png
And that just gives me one section of the page:
I tried adapting that and changed the 612x792 to 1275x1650, which would fit 150DPI multiplied by the size of the page (8.5" x 11"). When I did that, I got a large image, but, again, the margins were gone, like in the 2nd image above.
These images will be displayed in a Java program that will be displaying a number of pages, so the margins could vary (in other words, I can't just wrap a set border around the output, as seen in the 2nd image, since the border size will change in some images).
I've seen a number of hits on removing margins for PDF to PNG conversion, but they don't seem to provide anything to help me.
My guess is that, in the conversion process, the margins are converted to something transparent, so I tried adding "-transparent white" to the command line for convert, but it didn't help.
What can I do to either get the margins back or, if they're there and not visible, how can I get them to display? Basically I want the PNG file (image #2) to look like the PDF file with margins included (image #1).
I suspect I'm missing something obvious - I hope it's that easy.
How can I make sure the space in the margins show up?
I never got an exact answer, but one of the ImageMagick people was quite helpful with this. Basically, I needed to use the option "-extent" to specify how big the image was. Since I was using a different density than the default, I had to take that into account, too. The command line that worked was:
convert -density 150x150 InputFile.pdf -background white -units PixelsPerInch -density 150 -extent 1275x1650 OutputFile.png
The 1275x1650 comes from multiplying 150 (for the DPI) by 8.5" for the width and by 11 for the height.

How to get crisp image for search result suggestion in Windows 8?

I'm using a 40 x 40 sized image as a search result suggestion image in Windows 8 search. Only advice about the image format I can find is to have correct size for it (http://msdn.microsoft.com/en-us/library/windows/apps/Hh700542.aspx: "Windows will scale or crop smaller or larger images").
However, the correctly sized image blurs annoyingly. The same thing happens whether I use jpg or png. Original image looks fine, but the result suggestion in the search charm is very ugly, being still of same size! Is Windows converting the image somehow, and how could I get the image to stay crisp?
I haven't noticed blurring with photo-like images, but this image contains clear lines and areas which are vulnerable to any scaling etc.
Update Sep 24:
Here is the test image I used when trying to figure out the problem. I also created different scale versions, but in my case the 100% version was used (that's why the "100" marking) - as I supposed because the resulting image really is 40x40. As you can see, the resulting image (right) is of same size as original (left), but blurry.
it does not happen that often but it seems the right solution in this case was simply to wait ;) I haven't done anything new regarding result suggestion images in my solution and today I realized that the images became crisp. Probably fixed by any of the windows updates.
[Took a stab at answering what seems the related question mentioned in the comments, so I'm posting here as well.]
It sounds like this could be related to automatic scaling of the images. Windows will automatically scale up/down based on pixel density, and you can help things scale well by either using vector-based images or, for bitmap images, supplying scale-specific versions.
For example, to scale an image referenced in markup as "AppLogo.jpg", you'd include these images:
AppLogo.scale-100.jpg
AppLogo.scale-140.jpg
AppLogo.scale-180.jpg
You can also use folders, e.g. "\scale-140\AppLogo.jpg".
For search result images, the 100% image is the 40x40 pixel version, 140 is 56x56, and 180 is 72x72. Just reference the image as "AppLogo.jpg" and the appropriate version will be used automatically. (You can also detect scale with DisplayProperties.ResolutionScale and manually choose an image.)
Here's a couple of articles with more examples/details:
"Guidelines for scaling to pixel density"
"Quickstart: Using file or image resources"
There's also some scaling discussion in the forums (general, not specific to search) here and here.