I have an .jpg image that is generated by an application. What I want to do with it is, using java, blur out a box on the .jpg to a point where any text or content would not be able to be read, but doesn't aesthetically ruin the picture.
How would I go about doing this?
Edit:
I guess I'm needing more direction than just a simple how to do this. I don't have any background in image processing. What kind of java libraries or tools should I be looking at using?
Related
Is there a drawString method usable in java that will create scalable text that will be clear and crisp in a powerpoint presentation?
Backstory:
I screwed up. Big time.
A friend of mine asked for help with automating some graph creation for his company. The process involved taking in data values from a pdf file, then converting them into graphs to be exported into an image file that he could then use to place in a power point. I figured it would be easy enough to do in Java2D, and therefore used the Graphics library to do so.
The resulting image looks good, except that there is small text written by him through his manual process (which is done in excel), that I cannot replicate with my automated program. It seems that because he has created his image using excel this small text will scale well when blown up for a power point presentation, whereas when I use Java2D's drawText method it will look pixelated and blocky as this seems to draw it pixel by pixel.
I realize now that this would have been much better done using Visual Basic or through Excel macro's that are made with this sort of thing, however at this point I do not have the time to begin anew. :(
I need a solution to create one big image with sprites from ~100 single images periodically without intervention because the number of images and the images itself are changing over time. To create the sprites with e.g. http://css-sprit.es/ or any other toolu with a GUI would not be feasible.
Each image has a different width and height. Images formats are png, gif, jpg. My approach would be write a custom java program to concatenate the images vertically into one big image and create a json file to provide the coordinates for later processing. A google search returned me this java awt based tutorial:
https://sites.google.com/site/javagamescorner/home/creating-sprites
Is there another way you would recommend to create sprites? There are a lot of (too?) complex tools and libraries and maybe there is an easier solution.
This Stackoverflow thread mentions a lot of java libraries: open source image processing lib in java
Since you didn't mention Swing or SWT, I'm going to give you a SWT approach.
Engineer an ImageBuilder. Follow the builder pattern, and design it so that it suits your needs. Extend it from CompositeImageDescriptor (if you look at the class' APIs, you'll instantly figure out how to draw the images) to work with ImageDescriptors, construct your sprite, then eventually cache the result so it can be used later on.
In server side image process, should I use AWT or SWT?
I think AWT maybe too abstract away from the actual image data bits, so I guess SWT maybe slightly faster.
Or do you suggest another open source image process library? (BSD or Apache licensed)
The server is running Ubuntu 11.04.
Requirements:
Read/write image from/to stream instead of files.
The image type is given as parameter rather then guess from extension.
(This is optional if it can determine the image type from the header bytes.)
Support of JPG, PNG, GIF.
(Bonus) Support of Animated GIF.
Use cases:
Generate thumbnails.
Add some banner texts.
Add cryptic image watermark and validation.
SWT has very little in terms of image processing. The standard JDK image stuff has the fancy ImageIO package, and Java2D which can do pretty much everything. I'd call this a no-brainer: use Java's built-in stuff, and don't try to use SWT for something it's not intended for.
I can second Ernest's notion about SWT for this task, forget it.
But while Swing is fine for image manipulation and output, Swing's ImageIO fails too often during input: many images which you'll meet in the wild, and which work fine in the browser, produce Exceptions.
The best Java option I know of is JAI, which unfortunately is a pain to use. So do yourself a favor, and use JAI for input, and Swing for the rest, like this:
RenderedImage renderedImage = JAI.create("fileload", imageFile.getAbsolutePath());
RenderedImageAdapter planarImage = new RenderedImageAdapter(renderedImage);
BufferedImage image planarImage.getAsBufferedImage();
JAI will also fail in rare cases (JPGs with custom color space, as written by Photoshop, are an example). If you want to do even better, use ImageMagick, which is an ultra-powerful command line tool. There are Java interfaces available, which either provide an API for the command line, or use JNI to call the native library, see here.
I'm looking for a Java library that provides a simple image editor (like MS Paint) as a UI control. If it's extendable so I can add new editing tools, that would be great. I need to be able to save the edited image in either JPEG or BMP formats. This library must be free, and ideally is open source with a license compatible with including in closed source software.
My use case is I'm using Xuggle/MediaTool to extract frames from a video file. I then need to have the user cut out certain pieces of the image to create a mask for use in a video processing routine.
It is easy to roll one on your on. If you need really advanced capabilities, probably you can embed the editor from this open source Java project.
I made a "photoshop/mspaint" like Java project here : http://imagework.free.fr contact me through the "contact" page of the website, I can help you if you need.
To answer, for write an JPG/BMP image you can use:
BufferedImage image = "your image";
ImageIO.write(image,"BMP",BufferedImage.TYPE_BYTE_INDEXED);
or
ImageIO.write(image,"JPG",BufferedImage.TYPE_INT_RGB);
We have a java web application. The application generates a big image with company structure diagramm on it as jpeg. Users download the image and want to print it on DIN A2 (big paper format). The jpeg in this scale has pretty bad quality after printing.
Our idea is to generate an image in vector graphics. What vector graphics format suits the best our needs, considering that we code in java and the users have windows and use MS IE browser?
May be there is a better way archieve this? Like let the browser to display the image and let users to print the page?
PDF has been invented exactly for the same purpose. iText library enables you to draw lines, boxes, circles and insert whatever text you like. If you want to automate it a bit using templates there's JasperReports which utilizes iText.
A well known vector graphics format is Scalable Vector Graphics. It's basically an XML file (starting with <svg> tag. It can be viewed in browsers like Firefox without additional plugins.
For java, you can use the Java 2D API to create SVG format. A tutorial can be found here:
If you need the vector graphic for IE you need VML, similar to SVG but can be rendered by Internet Explorer.
RaphaelJS can be used for vector graphics independent of browser model but it's client side and you may not want to do client side processing on every page load.