Jump to content

Displaying images


ColdEdge

Recommended Posts

Hey, I am working on my own little forum/CMS project nothing fancy.. just something to help me/my friends out with site setup with out having to write HTML over and over.Alright at the moment when user uploads his/her photo the original file is unlinked and a new re-sized files are created. A large picture and a thumb are generated and the links are placed into corresponding MySQL fields.Some time back a friend of mine showed me a great social network site. The site was in Russian or something like that so I could not read anything ^^, but what I found interesting is the image system the site uses. The site allows user to upload 10 photos which can be used as accounts display pictures. However the interesting part is the photo is not shown as you typical http://............../..../user_####.jpg or something around those line which shows the image full location with extension.The site displays the images in this manner [url="http://random"]http://random[/url] server subdomain.maindomain.ru/getImage?photoId=209870360465&photoType=5So if you remove the photoType=5 part from the url you will be seeing the full image. Here is how the photoId=209870360465 image would look like [url="http://i25.tinypic.com/14lrb5x.jpg"]http://i25.tinypic.com/14lrb5x.jpg[/url]and here is how the same image looks like with &photoType=5 added [url="http://i27.tinypic.com/2u7sjmb.jpg"]http://i27.tinypic.com/2u7sjmb.jpg[/url] as you can see the &photoType=5 displays the upper part of the image rather then full image. My question here is how would I be able to achieve the same thing? So instead of my script echoing the image link location into <img src="..." /> it echo's the photoId and photoType (where applicable).here is a code I use to scale large images down, but for some reason the code takes a while to generate scaled down image...[code]// File and new size$filename = $_GET&#91;&#39;attachment&#39;&#93;;$percent = 0.45;// Content typeheader&#40;&#39;Content-type&#58; image/jpeg&#39;&#41;;// Get new sizes$ath = 2;list&#40;$width, $height&#41; = getimagesize&#40;$filename&#41;;$newwidth = $width/$ath;$newheight = $height/$ath;// Load$thumb = imagecreatetruecolor&#40;$newwidth, $newheight&#41;;$source = imagecreatefromjpeg&#40;$filename&#41;;// Resizeimagecopyresampled&#40;$thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height&#41;;// Outputimagejpeg&#40;$thumb, NULL, 100&#41;;imagedestroy&#40;$thumb&#41;;[/code]
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...