How to check a uploaded file whether it is an image or other file?

I’m assuming that you’re running this in a servlet context. If it’s affordable to check the content type based on just the file extension, then use ServletContext#getMimeType() to get the mime type (content type). Just check if it starts with image/. String fileName = uploadedFile.getFileName(); String mimeType = getServletContext().getMimeType(fileName); if (mimeType.startsWith(“image/”)) { // It’s an … Read more

Is there a simple way to get image dimensions in Ruby?

As of June 2012, FastImage which “finds the size or type of an image given its uri by fetching as little as needed” is a good option. It works with local images and those on remote servers. An IRB example from the readme: require ‘fastimage’ FastImage.size(“http://stephensykes.com/images/ss.com_x.gif”) => [266, 56] # width, height Standard array assignment … Read more

OutOfMemoryError while decoding and encoding Base64 String into Bitmap

When showing Bitmap in ImageView from a file first decode it with the help of BitmapHelper.decodeFile(picturePath, 200, 200, true) this will return compressed Bitmap so that while encoding this Bitmap you can handle high resolution images as well as heavy size images upto 100 MB of file. After decoding file set it to your ImageView … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)