Posts Under 'Image'

File upload using Java

First download Apache Jakarta Commons FileUpload library from this link and add into classpath of your Application. Validate HTTP Request Now that you have installed the FileUpload library, you can start writing the code. First, we have to make sure the HTTP request is encoded in multipart format. This can be done using the static […]

Read more »


The request doesn’t contain a multipart/form-data or multipart/mixed stream, content type header is null

org.apache.commons.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn’t contain a multipart/form-data or multipart/mixed stream, content type header is null If you are iterating the items from the multipart request without checking if an http request is encoded in multipart format then you will get this error. If ServletFileUpload.isMultipartContent(request) returns true then you need to get the fields via the […]

Read more »


PHP script uploads files and manipulates images very easily

class.upload.php – This PHP script uploads files and manipulates images very easily. The perfect script to generate thumbnails or create a photo gallery! It can convert, resize and work on uploaded images in many ways, add labels, watermarks and reflections and other image editing features. You can use it for files uploaded through an HTML […]

Read more »


Serving Image from Absolute Path in Java/J2EE

import java.io.*; import java.net.URLDecoder; import javax.servlet.*; import javax.servlet.http.*; /** * Serving Image from Absolute Path. */ public class ImageServAbsolutePath extends HttpServlet { private static final long serialVersionUID = 1L; private static final int BUFFER_SIZE = 10240; private String imagePath; public void init() throws ServletException { /*——- Image Base Path ———–*/ this.imagePath = "/images"; } protected […]

Read more »


Basic JPEG image resizing in Java

/* JpegResizerDemo.java */ import java.io.FileInputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.awt.image.RescaleOp; import java.awt.image.AffineTransformOp; import java.awt.geom.AffineTransform; import java.util.Map; import java.util.HashMap; import com.sun.image.codec.jpeg.JPEGImageDecoder; import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.ImageFormatException; import com.sun.image.codec.jpeg.JPEGImageEncoder; /** * @author CyranoVR */ public class ImageResizer { public static void main(String args[]) { if (args.length != 3) { […]

Read more »