Jump to content

Image size control


phunni
 Share

Recommended Posts

I am currently building a website where users will be able to upload images

 

Unfortuantely - I don;t know in advance how big the images will be. Is there a way, in normal html, of limiting the size of an image? If it's smaller then fine - but not let any images be above a certain size?

 

By the way - feel free to check it out here - just remember it's still a testing site and not everything may work yet. Register, search, edit - whatever you like, although I could do with some feedback on the functionality of the site. The design is not really done yet.

 

If you do register - please stick something in your "company" description that tells me it's you - so I know where it cam from

Edited by phunni
Link to comment
Share on other sites

I recently used pre-made php type sites that do this on my site (www button below). If you want to check them out: They use imagemagik and sizes are set in the configure / setup scripts.

 

http://gallery.menalto.com/index.php

http://coppermine.findhere.org/index.php

 

I wouldn't know how to hard-code something like this, but your welcome to borrow any of my pages to hack the script for your purposes.

Link to comment
Share on other sites

You could try something like this (although I haven't tested it myself)

 

img.test-default {

width:80px;

height:80px;

}

 

and

 

img.test-reduced50 {

width:40px;

height:40px;

}

 

 

assuming of course you have an 80x80 image.

 

Then something like,

 

<img src="img1.jpg" alt="original 80px by 80px image"

class="test-default" />

<img src="img1.jpg" alt="css 40px by 40px image"

class="test-reduced50" />

 

HTH,

Link to comment
Share on other sites

Please explain wat you have done - I don't understand it

 

Also - does anyone have a javascript solution. I know nothing about Javascript , but it seems like it might be easier tha doing it in Java...

 

(BTW - just to avoid confusion - it's worth clarifying that Java and javascript are unrelated apart from a similar name...)

Link to comment
Share on other sites

Please explain wat you have done - I don't understand it

 

assuming you have an image that is 80x80 - you could include it in your html with

 

<img src="img1.jpg" alt="original 80px by 80px image"

class="test-default" />

 

and within your css you could include:

 

img.test-default {

width:80px;

height:80px;

}

 

Now assuming you wanted this image resized to 40x40 simply within the page, you would have the following html:

 

<img src="img1.jpg" alt="css 40px by 40px image"

class="test-reduced50" />

 

and in the css:

 

img.test-reduced50 {

width:40px;

height:40px;

}

 

which, hopefully will produce a resized image totally though css and html utilising only the original image file.

 

You may also be able to do something server side with imagemagic (man convert) but I've only ever used this to create thumbnails and not on a server.

Link to comment
Share on other sites

I know... trouble is that I know nothing about javascript - so I'd need some pointers. I tried to do it in Java and, almost had it, but the Java classes require an X server to be running to manipulate images - and all this is done on a server with no X :(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...