?
Solved

Validating DPI while upload

Posted on 2007-10-01
4
Medium Priority
?
1,195 Views
Last Modified: 2009-12-16
I need a system that allow user to upload images. However while the image is being uploaded, the system should check if the uploaded image is in the allowed DPI.

EG:
If I set acceptable DPI to 300, if user try to upload an image with 100 DPI it shouldn't accept.

Also I know usual way of validating file format is to check its file extension, however is there any better way to validate the file format? Maybe thru the pattern? Like illustrator have different set of pattern compare to coraldraw..
0
Comment
Question by:learningProcess
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 19998054
In ASP no, in ASP.Net yes you can but you have to wait for the image to be fully uploaded first to be able to check it

<%@ Page Language="c#"%>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
  Bitmap bmp= new Bitmap(Server.MapPath("your_image.jpg"));
  Graphics g=Graphics.FromImage(bmp);
  Response.Write (bmp.HorizontalResolution + " dpi");
}
</script>
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21130326
Forced accept.

Computer101
EE Admin
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question