How to cut the png image as per the shape? - photoshop

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.

Related

Converting a PDF to PNG with anti-aliasing and transparent background

I am trying to convert a LaTeX-generated PDF file to a PNG file with anti-aliasing and a transparent background (white text on a black background). After having read the answer to this post and one of the comments to the answer, I compared the convert function of ImageMagick against pdftoppm. So far, the highest quality anti-aliased images that I can generate are using pdftoppm (for a given DPI resolution). I use the following command:
pdftoppm -png -r 2000 text.pdf > text.png
The equivalent command (or so I think) using ImageMagick was:
convert +antialias -interpolate Nearest -density 2000 text.pdf -quality 90 -colorspace RGB text.png
However, I did not get as good-quality anti-aliasing using ImageMagick as I did with pdftoppm. In fact there hardly seems to be any anti-aliasing in the ImageMagick-generated image. See the close-ups below:
pdftoppm image:
ImageMagick image:
So where this leaves me is that I am satisfied with the anti-aliasing that pdftoppm provides. However, ImageMagick seems to have more functionality in now converting the anti-aliased image such that the black background is transparent. I have applied the approaches detailed in this post using ImageMagick, but they compromise the quality of the anti-aliasing that was previously satisfactory.
Can anyone advise me on how to solve the issue of obtaining a transparent background (which will always be black in color) while not affecting the anti-aliasing quality? Additionally, if the ImageMagick command that I used above was sub-optimal for generating a high-quality anti-aliased image, is there a way that I can achieve both anti-aliasing as well as background transparency by using ImageMagick alone? Any form of advice/tips would be much appreciated!
P.s. Since this question is partially LaTeX-related (I use LuaLaTeX to compile the PDF), I have posted a related question here regarding whether there is a much more straightforward way of directly generating the PDF file with a transparent background.
EDIT:
I've managed to fix the issue of transparency based on some comments on the question I posted on the TeX stack exchange. Now it's just about how I can improve the quality of anti-aliasing. Is there a way that I can achieve the same quality anti-aliasing that I get from pdftoppm?
The pdf file that I am converting can be found on this Dropbox link. Note that the font colour is white, and the background shows as white too (in my pdf viewer anyway), but is transparent. This is the converted PNG file.
You should use -density to increase the anti-aliasing of your PDF to PNG conversion. I note that your image is opaque white and the text is simply in the alpha channel.
convert -density 600 text.pdf -alpha extract x.png
If on Imagemagick 7, change convert to magick.
If you want to keep the transparency and keep your text white, then
convert -density 600 text.pdf y.png
The image is above, but will look completely white and blend with the white background. So you will need to download it.
If you want black text on transparency, then
convert -density 600 text.pdf -alpha extract -alpha copy -channel rgb -negate +channel z.png

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.

Output from dcraw has checkerboard shading

I'm trying to use dcraw on a color image (e.g.CR or NEF) to extract raw monochrome data for image processing.
With parameters -4 -D -c I get an image with a checkerboard as shown below:
When unzoomed, the image data is correct, except for the checkboard pattern in all images from different cameras.
The above image was produced using -T and zooming in the resulting .tiff file in File Viewer Plus. In practice, I'm reading the .pgm file directly and getting the same checkboard.
What aren't I understanding? Does this have something to do with Bayer filtering?
Yes, this is due to Bayer filtering and no demosaicing. For example, Green areas will have green pixels brighter than red according to the Bayer pattern, whereas red areas will have green pixels dark.
To get some kind of correct grayscale (or color) image, intensity has to be weighed over a 2x2 area (in standard Bayer). What you are looking for cannot be achieved without the demosaicing step.
Your best bet is to extract a color image, then turn it into grayscale.

PDF - Mass cropping of non-whitespace application

I have about 400 pdfs with a lot of dead space between the text and the page border.
Usually I'm using govert's pdf cropper to crop all the whitespace, but this time the pdf background color is (darn!) yellow,
and no software which I know (and I've searched for quite a while) can crop non-whitespace
(well, except maybe pdfcrop.pl -a Pearl library which supposedly can remove black spaces).
Anybody knows of a software that can perform such task?
The ideal app, I guess, would have the option to receive specific color to remove,
like rgb(192,192,192).
Thanks in advance.
The reason this is so difficult is that PDF has no concept of paper color or background color. So what you're seeing is not a different background color, but an object (typically a rectangle) painted in that yellow background color.
Most cropping tools simply calculate the bounding box of all objects on the page and then crop away everything outside that bounding box. Of course that doesn't work for your file because the bounding box will include the background rectangle object.
There are potentially a number of directions you could take this:
1) If all pages need to be cropped by the same amount, you could attempt to do cropping that way (simply passing a rectangle to the cropping tool to do the actual cropping).
2) There are tools (callas pdfToolbox - watch it, I'm associated with this tool, Enfocus PitStop...) that allow you to remove objects from a document and this could be done by specifying your yellow color. This would allow you to modify the PDF file by removing the background object and then perform the cropping you want to perform.

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.