Applying filters to PNG Images

Hi
I would like to know how to implement filters or Operators such as Alpha filtering,LookupOp,ConvolveOp (or any kind of filter which makes the image blur or partially transparent) to a PNG Image and then revert back to the original image.
Thanks,Laksh

1. Have you tried doing the tutorial?
2. What do you mean by "revert back to the original image" -- are you trying to find filters that are the inverse of other filters?
Here's a demo. I create a buffered image, write it out to a png file and read it back in.
Then I convert its type (the blur filter didn't want to work, otherwise!!). I run the
image through the filter and save it to another file, displaying the images along the way.
import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
public class Example {
    public static void main(String[] args) throws IOException {
        File file = new File("temp.png");
        ImageIO.write(createSampleImage(), "png", file);
        BufferedImage source = ImageIO.read(file);
        System.out.println("type = " + source.getType());
        BufferedImage converted = convertType(source, BufferedImage.TYPE_INT_RGB);
        BufferedImage blurred = blur(converted);
        ImageIO.write(blurred, "png", new File("blurred.png"));
        JPanel panel = new JPanel(new GridLayout(0,1));
        addImage(panel, source, "from png file");
        addImage(panel, converted, "TYPE_INT_RGB source");
        addImage(panel, blurred, "blurred image");
        JFrame f = new JFrame("Example");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setContentPane(new JScrollPane(panel));
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    static void addImage(Container cp, BufferedImage image, String title) {
        JLabel label = new JLabel(new ImageIcon(image));
        label.setBorder(BorderFactory.createTitledBorder(title));
        cp.add(label);
    static BufferedImage createSampleImage() {
        Font font = new Font("Lucida Bright", Font.ITALIC, 72);
        String text = "Sample Text";
        Rectangle2D bounds = font.getStringBounds(text, new FontRenderContext(null, true, true));
        int w = (int) Math.ceil(bounds.getWidth());
        int h = (int) Math.ceil(bounds.getHeight());
        BufferedImage image = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
        Graphics2D g = image.createGraphics();
        g.setFont(font);
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
        g.setPaint(Color.WHITE);
        g.fillRect(0, 0, w, h);
        g.setPaint(Color.BLACK);
        g.drawString(text, (float) -bounds.getX(), (float) -bounds.getY());
        g.dispose();
        return image;
    public static BufferedImage convertType(BufferedImage source, int type) {
        if (source.getType() == type)
            return source;
        BufferedImage result = new BufferedImage(source.getWidth(), source.getHeight(), type);
        Graphics2D g = result.createGraphics();
        g.drawRenderedImage(source, null);
        g.dispose();
        return result;
    static BufferedImage blur(BufferedImage image) {
        BufferedImage result = new BufferedImage(
                image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
        float ninth = 1.0f / 9.0f;
        float[] kernel = {ninth, ninth, ninth, ninth, ninth, ninth, ninth, ninth, ninth};
        ConvolveOp op = new ConvolveOp(new Kernel(3, 3, kernel), ConvolveOp.EDGE_NO_OP, null);
        return op.filter(image,result);

Similar Messages

  • Is it possible to apply a PNG image *and* a gradient to a single div background?

    I am looking to create a div that will have a css gradient as a background, but also a PNG image to go on top of that gradient. This div will also contain text.
    So the desired stacking order is :
    Top : Live Text
    Middle : PNG image
    Bottom : CSS Gradient
    Question : Can this be done with only 1 div?
    I know that if you specify a background image AND a background color on the same div, you will get both, and it works quite well. But it seems much more complex to do it with a gradient instead of a flat bg color.
    If it's do-able, what would the syntax be?
    Thanks!

    Hi
    You could also use multiple background images, though this will not work in IE8 or below, (use Nancys 'stacking order' as a fallback but specify these first).
    #multipleBackgroundImages {
      background-image: url(gradient.svg),
                        url(your_image.jpg);
      background-position: top left, bottom right;
      background-repeat: no-repeat;
    see also - http://www.css3.info/preview/multiple-backgrounds/
    I specify an svg as the first image as this will work across all modern browsers.
    For IE8 or below -
    You could use an IEFilter for the gradient and an image over that, providing your image is not too large, or use the IEFilter 'alphaImageLoadeer' to place the image in the top r/h corner of the div, with the gradient below.
    PZ

  • Inserting PNG images in my document makes text bolder

    I created a simple InDesign file using text and JPG images. So far all fine.
    But on pages where I use PNG images instead of JPG images all text on the page is slightly bolder as if some sort of overprint would apply to all text boxes, even the once placed on the Master Page.
    I checked all overprint settings, it's not it.
    Any idea?
    Thanks
    ralph

    That is indeed the problem.
    Any ohter workaround than flattening the images in Photoshop?
    Thanks
    ralph

  • Ability to add artistic filters to HDR image created in CS5?

    Hi,
    I created an HDR image last night in CS5 but it wouldn't let me apply any of the artistic filters to it.  Is that just not possible or must I do something else first in order to apply filters?   It seems to work fine with HDR created in Photomatix...just wasn't working on the one I created in Photoshop.
    Thanks for your help!

    As I work around, I found that you can save the image off as a jpeg, then open that version to edit and you are able to apply any of the filters (artistic/brushstrokes/distort, etc.).  If anyone knows of an easier way, please let me know.
    Thanks!

  • I am trying to use photomerge compose.  I open one standard jpeg image and one image that is my business logo in a png format.  When I select the png image, to extract the logo from it, it appears as all white and will not allow me to select the logo from

    I am trying to use photomerge compose.  I open one standard jpeg image and one image that is my business logo in a png format.  When I select the png image, to extract the logo from it, it appears as all white and will not allow me to select the logo from it.  It has worked in the past but I downloaded the update today and photomerge will not work correctly.  Any ideas?

    hedger,
    How do you expect anyone to help when we don't know a darned thing about the file, abut your setup, exact version of Photoshop and your OS, machine specs, etc.?
    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • How can I add .PNG images to templates without getting a white background?

    I'm having problems with a image field when I add a .png image which doesnt have a background it is showing up with a white background. Is it possible to use images in templates so you can overlay them on something else?

    Hi, You can do this but only with a PNG with a palette of 256 colors (maybe GIF as well) so doesn't get a lot of use, good enough for image buttons and the like, but might be ok for your image as it does not have that many colors. Otherwise radzmar's suggestion would be the better approach.
    This is the link I was tring to find (in your previous thread) that tells how to do it using GIMP (a free image editor), http://smartforms.business.gov.au/DeveloperResources/Pages/HintsandTips.aspx ,  but the one I have uploaded here comes from photoshop (in photoshop it is called an indexed png).
    Regards
    Bruce
    p.s. I'm always on the lookout for a new beer to try if this one you would recommend? 3% and all.

  • How to load a PNG image from a location in CF card

    Hi,
    I am using WTK 2.5.2. I wanted to load a PNG image to Image object. The image is loaded when I have it in the classes folder. But I want to select different image from a different location. If I try to open an Image to createImage(String) from a different location, I get IOException.
    Please help me.
    Thanks
    Deekshit M

    I got the answer, I should be using Image.createImage(InputStream) API. It works fine.
    Thanks
    DM

  • Use SVGAnimator to display a SVG with xlink PNG image

    I tried the M2GDemo and it works without this image part
    SVGAnimator animator =
    SVGAnimator.createAnimator( image );
    // add our custom event listener
    animator.setSVGEventListener(
    new CustomEventListener( image, animator ) );
    // get the Canvas for this player: requires a cast
    Canvas canvas = (Canvas) animator.getTargetComponent();
    I modify the requestResource a bit to get Image from root1.
    public void requestResource(ScalableImage inImage, String inURI)
         int pos = inURI.indexOf(":");
         if (pos >0){
              inURI = inURI.substring(pos);
         inURI = "file:///root1/"+inURI;
    try
    Connector.openInputStream(inURI);
    catch ( IOException ioe )
    ioe.printStackTrace();
    <image x='90.0' y='69.46001' width='222.7' height='152.25' xlink:href='myImage.png'/>
    Now I stuck with the error below.
    Using Pisces Renderer (native version)
    loadStarting : true
    loadComplete : true
    loadingFailed: false
    loadStarting : true
    loadComplete : true
    loadingFailed: falsejava.lang.ArrayIndexOutOfBoundsException
         at com.sun.perseus.model.Text.applyXMLSpaceDefault(+86)
         at com.sun.perseus.model.Text.applyXMLSpace(+37)
         at com.sun.perseus.model.Text.layoutText(+70)
         at com.sun.perseus.model.Text.checkLayout(+13)
         at com.sun.perseus.model.Text.paint(+12)
         at com.sun.perseus.model.ModelNode.paint(+9)
         at com.sun.perseus.model.StructureNode.paint(+16)
         at com.sun.perseus.model.ModelNode.paint(+9)
         at com.sun.perseus.model.StructureNode.paint(+16)
         at com.sun.perseus.model.ModelNode.paint(+9)
         at com.sun.perseus.model.DocumentNode.paint(+16)
         at com.sun.perseus.model.SimpleCanvasManager.fullPaint(+108)
         at com.sun.perseus.model.SimpleCanvasManager.updateCanvas(+18)
         at com.sun.perseus.midp.SVGCanvas$1.run(+87)
         at com.sun.perseus.util.RunnableQueue.run(+271)
    RunnableQueue terminatingUncaught exception java/lang/ArrayIndexOutOfBoundsException.
    Bascially all I need is a viewer to display SVG with xlink to PNG image without the use or tinyline. If I want to get the PNG image from http, what should I do?
    Any response will be greatly appreciated.

    > This technique is really just using a BEE, there is
    > documentation on the BEE concept in the online help
    > and Brian McKellar has a weblog on the subject as
    > well.
    OK, I think I get the idea. Will check the stuff. Thanks.
    > Notice the strange D at the end of the line. This
    > isn't in the original posting. Perhaps this is just
    > bad cut and paste.
    Just bad copy paste. Yes.
    > You say that this isn't working for you - but you
    > don't describe the results. Is there an error?  Does
    > it render anything in the button at all?  Does the
    > raw HTML get rendered?
    I just saw coding in the button.
    > You want to make sure that the
    > text doesn't get encoded - which would cause the HTML
    > source to display instead. On the htmlb:button you
    > will want to set the attribute encode = FALSE.
    OK, that was right on spot. This shows me the Icon! Strike!
    > Also I am not sure that you can also pass in text
    > with the image like that.  You might have to create a
    > full BEE and add the image and a textView separately
    > into the BEE.  Then render the entire BEE to a string.
    I'll check the documentation on BEE and give it a try.
    Thanks for your answer.
    Thats a starting point for me.
    Alf

  • Placed PNG images which are made in 3ds max are not shown correctly in Ilustrator

    Hello,
    Why placed PNG images (renders) which are made in 3ds max (and then photoshoped) are not shown correctly in Ilustrator. Images appear very noise so you can't see almost a thing. the same pictures (renders) made in Revit appear ok.
    Is there a solution to solve this issue?
    Thanks.

    You would have to provide screenshots of how it looks in PS, including the channels visible. MAX may have embedded extra channels that throw off AI. And of course check whether your PNG is actually 8bit, not 16bit.
    Mylenium

  • PNG images revive deleted images in the form of a thumbnail, potential risk

    Saving a PNG image will revive deleted photos. To replicate this, save a PNG image, such as the ones on XKCD's "What If?", and deleted images get revived in the form of a thumbnail overlapping the image.
    This has been here since IOS 5, according to http://appleinsider.com/articles/13/11/14/bug-resurrects-deleted-image-thumbnail s-in-ios-7-photos-app-dates-back-to-ios-5
    Knowledge of this could be abused. If I get free acess to someone else's Ipad, I can just spam saving PNG images over and over to see their sensitive images saved as a thumbnail overlapping the PNG image's thumbnail.
    How do I delete the thumbnails? It seems that when you delete a photo, it saves the thumbnail. This is supported by the PNG images reviving deleted photos in the form of thumbnails.

    Send feedback/suggestions to Apple.
    http://www.apple.com/feedback/ipad.html
    Submitting Feedback to Apple
    https://sites.google.com/site/appleclubfhs/support/advice-and-articles/submittin g-feedback-to-apple
    File an Apple Bug Report, at http://bugreport.apple.com/
     Cheers, Tom

  • Safari on iphone won't render cgi generated png images with query strings

    I've got a cgi app functioning as a web service that generates png images and serves them up as part of another app which marshals them up in HTML.
    Here's the image stand alone:
    http://cybre.net/maps/mapgen.pl.png?WIDTH=1024&HEIGHT=768
    and here's how I marshal it:
    <IMG CONTENTTYPE='image/png' SRC='http://cybre.net/maps/mapgen.pl.png?WIDTH=1024&HEIGHT=768'>
    It seems to work on firefox, epiphany and galeon web browsers for linux, and my windows friends say that internet explorer renders them okay as well.
    My only apple hardware is my iphone, and safari pretends that there is no content when it renders the HTML page. Safari on the iphone does not render even using a direct link.
    The png is generated by perl mapscript, $img = $map->draw;
    print "content-type: image/png\n\n";
    $img->write;
    close(STDOUT)
    On the previous version of the iphone firmware, and before i factored the image generation out into a web service, the iphone was able to render the png image successfully.
    Is this safari wierdness where it gets cranky that there is
    QUERY_STRING info after the .png? mapgen.pl.png?foo=bar ?
    If so, are other browsers just being hyper liberal in what they accept and safari is playing by the rules or is this a bug in safari?
    thanks in advance,
    -marc

    it turns out that safari's handling of png is broken, the problem reproduced on both iphone and mac safaris.
    in changing the format to gif, it all works okay.
    does apple allow mortals to file bugs against safari?

  • Files with .png images create huge .pdf's

    I use .png images in PowerPoint presentations and these seem to create huge .pdf files. (...don't have this problem using .jpg images) For example, I have a 48 slide presentation that has a small .png image in the "slide master" so it will show up on every page. The PowerPoint file is 2.3MB, however the .pdf of it is 33.3MB, making it WAY too big to email, which was my objective.
    Any ideas on how to reduce the size of .pdf's which contain .png images?
    ...note that I "compressed" the .png images inside of PowerPoint prior to creating the .pdf, but this made no impact.
    Thanks,
    pm

    >I have a 48 slide presentation that has a small .png image in the "slide
    >master" so it will show up on every page.
    PowerPoint only has to store one instance of the image even thought it is
    displayed on multiple slides. But Acrobat can't do the same, the image has
    to be stored for every page that it appears on, so that would explain the
    larger file size.
    Acrobat is supposed to be able to optimize the storage of common background
    images (at least that's the message I see when I do a "Save as..."), but I
    have yet to see it to work. Maybe it depends on the application the orginal
    file is created in and the PDF conversion method used.
    Adding the image into a PDF file later as a watermark instead may be a way
    to keep the size down (then it really only does store the object once),
    though I believe that watermark images will appear in front of everything
    else on the page (not sure if that's a problem for you, it depends on
    whether any text or objects in the presentation ever appear in front of the
    image).
    What are the dimensions and resolution of the image in PowerPoint? You may
    be able to go as low as 75 dpi and not notice a difference, it depends on
    whether the image contains any areas of high contrast or text.

  • Firefox asks what to do with some PNG images instead of just displaying them

    Not sure what is going on here, but some PNG images seem to confuse Firefox, while others are fine. While some PNGs just display when clicked on (eg: when wanting to see a full size image from a thumbnail), others make Firefox ask what I want to do with it. When I select "Firefox 3.6.8" it ends with an error:
    /tmp/elementary_gtk_theme_by_DanRabbit-1.png could not be opened, because an unknown error occurred.
    Try saving to disk first and then opening the file.
    ... but when I manually made it open with "/usr/bin/firefox" (I'm in Ubuntu) the image opens fine. I was beginning to think this was now universal for PNGs, but I was opening offending ones from the same site, and going elsewhere showed that some PNGs will be displayed as usual. Does anyone have any idea why this would happen to some PNGs but not all? Here is a link to one of the problem PNGs:
    http://s.linux-mag.com/i/articles/7811/elementary_gtk_theme_by_DanRabbit.png
    It opens without issue in Opera. Hope someone can make sense of this. Cheers

    You can look at this extension:
    *Open in Browser: https://addons.mozilla.org/firefox/addon/8207

  • Displaying the .png image stored in an byte array

    Hi,
    I have to download an .png image from a server and i have to store it in a byte array and i have to display this byte array in another servlet. I have written the code to get the image from the remote server in a java class. The java class returns the byte array of the image and i have to display that in an servlet.
    If anybody has the code or any refrence to refer please help me..
    Thanks & Regards
    -Sandeep

    I have pasted code for servlet's doGet method which writes image data...
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws
    ServletException, IOException
    HttpSession session = request.getSession(); //taking httpsession
    response.setContentType("image/jpeg");
    ServletOutputStream out = response.getOutputStream(); //taking outputstream of response
    if (rtn.getErrorCode() == 0)
    //this will actually write image file data from where it is being called
    //byte array will contain image data, please load your image into below byte array variable
    byte[] b = new byte[100];
    out.write(b);
    out = null; //making null
    session = null; //making null
    In other servlet, write <img> tag and specify its src attribute to the "name of servlet where u have pasted above code" ..
    Regards,
    Nikhil

  • Prority applying filters in Develope module

    LR is one of the best tools for those who wnat quick ranking, metadata editing for copyright, sorting and processing LARGE quantities of files...
    Among those photographers wedding, event and sport shooters are those who really need to fastly sort thigns outm they are most interested in using LR.
    also, the same photographers work in the most critical lightning environments, very often we shoot in very bad lightning at very high ISO settings.
    for us noise is a real pain.
    as we all know, advanced processing of a very noisy raw material exponentially increase noise levels in the final product.
    for this reason, inside PS, our workflow include NR filters among the first operations we do...
    this way, working on a cleaner background, the noise is kept under a relative control.
    often, at the end of our workflow we again trim the nise as a final touch...
    back to lightroom, few questons and requests are born from this imediate reality we confront each day:
    1. LR offers NO control regarding order develope adjustments are applied... this is sometimes good, other times a real pain...
    2. there is no information regarding WHICH is the order those filtes are applied when developing RAW files... NONE.
    we could guess the order they appear in XML files and inside develope module is the order they are considered when RAW information is processed?
    that mean noise is indeed among the last filters applied, correct me if i am wrong.
    3. how we could maximize our results? just make minimum adjustments in LR, go to PS, where we can control the order of applying filters, process and export from there???
    not exactly compatible with our need for speed and easy processing large quantities of files that make us choose LR, isn't it?
    not to mention RAW data offers much more "hidden" info we can bring to life thru processing compared to exported PS files, even 16 bit tiffs are not as "good" on this regard...this is the reason we shoot raw, to benefit from this better latitude of information raw's offers ....
    4. now the requests themselves:
    a} please allow us to choosethe order of applying these filters...maybe not all, not all are that critical, but things like NR we should be able to put among the first filters applied.
    if Adobe already thought about this and NR is among the first on that list, please let us know. we NEED to know , we need that info, we need control.
    b} please allow us to double the filter alteration.
    as i said, we often apply a NR fiter at the beggining of the workflow and then again, another NR with softer settings at the end of the workflow, sometimes just before the final sharpening.
    such flexibility and customization availability would really help us, especially those who really need lightroom and do not have the time to bring every picture in PS and tweak it...
    imagine shooting 1000 pictures in one session with a delivery deadline of 24 hours...LR is great help, have a lot of great features and we really apreciate the wayit works, even this elastic way of applying filters inside develope module...
    BUT it would be a much better tool with more flexibility available.
    Thanks Adobe, i also compelted an official request form regarding this subject.
    maybe someone who really knows how things work inside developing engine could bring some light in this regard, how things really work right now,even this info could be very helpfull.
    regards ,Liviu

    first i need to KNOW officially how thigns work, if ucan offer me a proof i'd gladly accept that.
    second, as i said, adobe might have think about that, is a request area and i have theright to request what I think is usefull to me.
    i ask for more CONTROL, what is wrong about that?
    i also request for 2 alteration using the same filter, NR in this case, once at the beggining and one at the eng of the developing process, i am also entitled to ask for such a thing, right?
    qith all due respect, if u do not have similar needs please allow me to ask , understand and not suppose adobe thought of everything and there is no better way, ok?
    here is a quote from a XMP file, i PRESUME the order if operation inside that file is the one processes are piped, am i wrong again?
    5.3
       As Shot
       4900
       -2
       -0.57
       15
       +79
       -7
       +33
       25
       39
       18
       0
       0
       0
       0
       0
       0
       0
       0
       0
       0
       17
       -21
       29
       +10
       0
       0
       0
       0
       0
       0
       0
       0
       0
       0
       0
       0
       0
       0
       0
       0
       0
       +60
       0
       -24
       0
       +19
       0
       -24
       0
       0
       0
       0
       0
       0
       0
       0
       0
       0
       25
       50
       75
    +1.0
       25
    0
       0
       False
       Medium Contrast
         0, 0
         32, 22
         64, 56
         128, 128
         192, 196
         255, 255
       ACR 3.3
       8E1722706FEF96E97D62F657E50DF272
       True
       False
    so ,as u see i spaced the noise reduction fucntions in order to make them more visible, i can;t use colors to underline what i consider important, ok?
    SO, as u can see here, WB, exposure, contrast, SHARPNESS, brightness, SHADDOWS are ALL listed BEFORE noise reduction...
    later on the end of the list there is ANOTHER sharpening listed, so double fiter IS ALREADY applied, thus possible, right???
    again, ALL fiters applied BEFORE NR influences noise levels, all increse noise, more or less....
    WB influences exposure, try to go 50000 and see where hystogram goes to the right...
    exposure also increase noise in shaddow areas.
    contrast increse noise.
    brightness also influence noise.
    Shaddows are working exactly on most noisiest levels, the shades...
    sharpness before NR??? indeed, is "well thought"...
    so, Lee jay, seems i am not that wrong after all, isn't it???
    i really hope that order inside XMP to mean nothing but i really doubt is meaningless ...
    and again, even if a were wrong, i am entitled to ask explanations as i pay for this product. I also am entitled to ask for what i consider improvements, if Adobe decide to implement or not is another discussion...
    a little "friendlier" tone in your replies would also be apreciated, thank you in advance. i hope u do not work for Adobe ;)
    so, i am waiting for documented proofs related to my questions, thank you Adobe.

Maybe you are looking for