473,413 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Problem in reducing the image size

Hi,

I am having a Image of size width=700 and height=500, I want to reduce the image and display it within the allocated space of width=400 and height=300.
I am using the following javascript code to reduce the image in proponate ratio.

if(iImageWidth > 400 || iImageHeight > 300){
while(!(iImageWidth <= 400 && iImageHeight <= 300)){
iImageWidth = iImageWidth * 0.99;
iImageHeight = iImageHeight * 0.99;
}
}
x.width = iImageWidth;
x.height = iImageHeight;

Everything is working fine and i am getting the reduced image. But my problem is the result image get distorted (Its not clear as the original image). When we zoom in a image its clear but when we reduced the width and height its not clear as zoom in image.
Please help to resolve this issue.
Thanks in advance.
Jul 11 '07 #1
3 6821
nomad
664 Expert 512MB
Hi,

I am having a Image of size width=700 and height=500, I want to reduce the image and display it within the allocated space of width=400 and height=300.
I am using the following javascript code to reduce the image in proponate ratio.

if(iImageWidth > 400 || iImageHeight > 300){
while(!(iImageWidth <= 400 && iImageHeight <= 300)){
iImageWidth = iImageWidth * 0.99;
iImageHeight = iImageHeight * 0.99;
}
}
x.width = iImageWidth;
x.height = iImageHeight;

Everything is working fine and i am getting the reduced image. But my problem is the result image get distorted (Its not clear as the original image). When we zoom in a image its clear but when we reduced the width and height its not clear as zoom in image.
Please help to resolve this issue.
Thanks in advance.
Don't do it that way. If you have an application that can retouch images I would do it that way. Look for a selection/item that can increase or decrease images. Keep your dpi at 72 to 142 any thing above that is overkill.
MS Photo Editor can do this
there is a website that give you a free application for this called gimp
http://www.gimp.org/
it's simular to photoshop

nomad
Jul 12 '07 #2
Just to support what Nomad said, it's best to use a photo editor to resize images, rather than leave it up to the browser or a script. Even when the scale is kept, it's never as clear. I know a lot of people try this to avoid having a huge library of images, but think that when you load an image, you're loading it's full file size, even though it displays smaller.
Jul 13 '07 #3
Another thing you can try, if you want to be artistic (like you're doing a portfolio) is to just show a portion of the larger image. So, it acts as a teaser ... you can put the image inside a small div, that has styles like:

.box {
height: 50px;
width: 50px;
overflow: hidden;
}

Now, you can also use positioning to show the specific area of the image you want ... just keep in mind the browser still has to download the complete image file.
Jul 16 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tommie Nygren | last post by:
For different reasons I am reading an array of bytes from a file in my ..jar-file and from this I want to create a PNG image using Image.createImage(myArray, 0 , myArray.length). I had a...
0
by: Andreas Suurkuusk | last post by:
Hi, I just noticed your post in the "C# memory problem: no end for our problem?" thread. In the post you implied that I do not how the garbage collector works and that I mislead people. Since...
3
by: navavil | last post by:
Hi A few days ago we released new version of our Front Page (http://www.nana.co.il/) The page gui is based on html + css and its appeard to have problem uploading the images for all the...
4
by: Arif Çimen | last post by:
Hi to everybody, I have chnged a button text in design mode. But After compiling and executing the program the text of the button do not change to new value. Any Ideas? Thaks for helps.
5
by: Shawn Hamzee | last post by:
Hello All, I am having a problem with Image_Graph on php 5.1.4. I installed the package and all of its dependencies through pear installer without any hitches. Then I started to add some very...
4
by: RE Kochanski | last post by:
I have attempted to use the CSS techniques from two or three sites to create a CSS only image gallery. I am muddling the affair by placing the thumbnails in one float, the page text in another...
9
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo"...
7
by: raknin | last post by:
Hi I have a carousel script. I want to load the carousel with a new set of pictures every time I press a button. The problem that I have that the script append the new pictures to the olds one...
1
by: Sinan Alkan | last post by:
Hi All, I have a method to resize any image file to the specific dimensions and save this new image to a path. I found it on a web page(By Joel Neubeck) and i changed it for my project. The...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.