|
#1
|
|||
|
|||
|
Latest update: Applied to the 1.4.3 fix.
Download from pixelpost.org: http://www.pixelpost.org/v1/index.ph...ads&details=64 Download from jondrews.com: http://www.jondrews.com/pixelpost_v1..._mod_utoks.zip I really liked this script but there were a few things that were somewhat annoying when it came to uploading images. My camera takes large images and often, I'll just want to post the image without doing any modifications in Photoshop or the like. So I decided that if the pixelpost script resized my images to 600px wide and whatever fit for the height, it would really help me out. After hacking around with the code I got it working. I also added another set of lines that creates wallpaper versions of the image provided that it is larger than 1280x1024. The mod is relativly easy. It cannot be an addon because of the place that it must be executed. An addon could only resize after the fact. Anyhow--> Download the zip file http://jondrews.com/pixelpost_v1.4_w..._mod_utoks.zip EDIT: I updated to 1.4 a while ago-- the mods download section is down so here it is on my page. Once hte new mod comes out past 1.4.1 I'll do an update. I also plan on figuring out that jhead stuff so it'll keep the exif data on resize. Here is what I did. Around line 294-295 and beyond--> this is what I did: Code:
// prepare the file
if($_FILES['userfile'] != "") {
//utoks mod --> moved $filenamn up so it could be used in resizeimage
$filnamn = $_FILES['userfile']['name'];
//end utoks mod
$uploadfile = $upload_dir. $_FILES['userfile']['name'];
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
//this is utoks' mod --> creates wallpaper
// chmod($uploadfile, 644); removed--> resizeimage does the chmod() now.
$imagesize = getimagesize($uploadfile);
$imagewidth = $imagesize[0];
$imageheight = $imagesize[1];
if($imagewidth>=1280){
createwallpaper(array("file" => $filnamn, "max_width" => "1280", "max_height" => "1280"));
}
//end utoks mod
//this is utoks' mod --> resizes image(just like createthumbnail)
resizeimage(array("file" => $filnamn, "max_width" => "600", "max_height" => "600"));
//end utoks mod
$result = check_upload($_FILES['userfile']['error']);
if($headline == "") {
$headline = $filnamn;
}
//utoks mod--> there was $filenamn here-- but i moved it up.
$filtyp = $_FILES['userfile']['type'];
$filstorlek = $_FILES['userfile']['size'];
$status = "ok";
} else {
// something went wrong, try to describe what
echo "Error";
$result = check_upload($_FILES['userfile']['error']);
echo "<br>$result<hr>";
$status = "no";
} // end move
} // end prepare of file
Code:
function resizeimage($args) {
// credit to codewalkers.com - this is 99% a tutorial there
//utoks added this--> only difference is the place it puts the images.
$file = $args['file'];
$max_width = $args['max_width'];
$max_height = $args['max_height'];
define(IMAGE_BASE, "../images");
$image_path = IMAGE_BASE . "/$file";
$img = null;
$ext = strtolower(end(explode('.', $image_path)));
if ($ext == 'jpg' || $ext == 'jpeg') {
$img = @imagecreatefromjpeg($image_path);
} else if ($ext == 'png') {
$img = @imagecreatefrompng($image_path);
} else if ($ext == 'gif') {
$img = @imagecreatefromgif($image_path);
}
if($img) {
$width = imagesx($img);
$height = imagesy($img);
$scale = min($max_width/$width, $max_height/$height);
if($scale < 1) {
$new_width = floor($scale*$width);
$new_height = floor($scale*$height);
$tmp_img = imagecreatetruecolor($new_width,$new_height);
// gd 2.0.1 or later: imagecopyresampled
// gd less than 2.0: imagecopyresized
if(function_exists(imagecopyresampled)) {
imagecopyresampled($tmp_img, $img, 0,0,0,0,$new_width,$new_height,$width,$height);
} else {
imagecopyresized($tmp_img, $img, 0,0,0,0,$new_width,$new_height,$width,$height);
}
imagedestroy($img);
$img = $tmp_img;
}
}
imagejpeg($img, "../images/$file");
$resizedimage = "../images/$file";
chmod($resizedimage, 0644);
}
Code:
function createwallpaper($args) {
// credit to codewalkers.com - this is 99% a tutorial there
//utoks added this--> only difference is the place it puts the wallpaper versions.
$file = $args['file'];
$max_width = $args['max_width'];
$max_height = $args['max_height'];
define(IMAGE_BASE, "../images");
$image_path = IMAGE_BASE . "/$file";
$img = null;
$ext = strtolower(end(explode('.', $image_path)));
if ($ext == 'jpg' || $ext == 'jpeg') {
$img = @imagecreatefromjpeg($image_path);
} else if ($ext == 'png') {
$img = @imagecreatefrompng($image_path);
} else if ($ext == 'gif') {
$img = @imagecreatefromgif($image_path);
}
if($img) {
$width = imagesx($img);
$height = imagesy($img);
$scale = min($max_width/$width, $max_height/$height);
if($scale < 1) {
$new_width = floor($scale*$width);
$new_height = floor($scale*$height);
$tmp_img = imagecreatetruecolor($new_width,$new_height);
// gd 2.0.1 or later: imagecopyresampled
// gd less than 2.0: imagecopyresized
if(function_exists(imagecopyresampled)) {
imagecopyresampled($tmp_img, $img, 0,0,0,0,$new_width,$new_height,$width,$height);
} else {
imagecopyresized($tmp_img, $img, 0,0,0,0,$new_width,$new_height,$width,$height);
}
imagedestroy($img);
$img = $tmp_img;
}
}
imagejpeg($img, "../images/wallpaper/wall_$file");
$thumbimage = "../images/wallpaper/wall_$file";
chmod($thumbimage,0644);
}
A few things you can change. If you want to change the size of the image when it is resized--> just change the max_width and max_height that you pass into resizeimage() Code:
resizeimage(array("file" => $filnamn, "max_width" => "600", "max_height" => "600"));
Code:
resizeimage(array("file" => $filnamn, "max_width" => "800", "max_height" => "800"));
Also--> the same goes for the createwallpaper(). Just change these: Code:
if($imagewidth>=1280){
createwallpaper(array("file" => $filnamn, "max_width" => "1280", "max_height" => "1280"));
}
Code:
if($imagewidth>=1024){
createwallpaper(array("file" => $filnamn, "max_width" => "1024", "max_height" => "1024"));
}
Code:
<a href="images/wallpaper/wall_<IMAGE_NAME>">wallpaper</a> Ok-- I think that covers everything. If you have trouble just post here and I'll try and help you out. You could also email me at fjood@inmail.sk Peace. Last edited by utok; 11-23-2005 at 12:25 AM. |
|
#2
|
||||
|
||||
|
utok, make a .zip file of your entire admin/index.php where these modifications are in place. I think most people will find it easier to just replace their admin script with this one, instead of looking for lines and copy/pasting, which also can create invisible gremlins rendering the file unusable.
cheers // pixelpunk (you can also create an "developer" account on the front page of pixelpost site, and upload your zipped admin there.
__________________
icq: 66760929 |
|
#3
|
|||
|
|||
|
I just posted the modified index.php. I hope it works for the rest of you. I checked it over again just to make sure there were no hardcoding of my directories. I have not tested it on another server so I don't know for sure if it will work in a different environment. But I think it will....
|
|
#4
|
|||
|
|||
|
rotate image function
Hi all Pixelpost addicts.
First Thanks Mr PixelPunk for your great piece of software. As i'm a bit lazzy and really enjoy the utok addon which avoid the use of extra software (from camera right to the pixel post admin).. i develop a small addon to allow the image rotation...(90°CW - 90°CCW - 180°). But here's my problem : I have changed many things in the admin part... dividing the main file into many (such as functions.php / style.css..) and rewriting the main imageresize function into one for handling thumb, reg size, and wallpapers. Arghhh... one more thing... i added the option of the regular image size as suggested by Utok... so you can set the image size to 600 or 500... but this can be done upgrading the config table One more thing... wallpaper became an option... if checked while posting a new image it will create a wall if not... so if someone is interested by this add_on... just let me know. |
|
#5
|
|||
|
|||
|
Ahh! I am doing the same thing! I just rewrote the whole admin, added a new table and all.... But I am not done, so I would just want your changes!
We should establish a cvs repository or something
|
|
#6
|
|||
|
|||
|
I just updated the mod to work on 1.3. It should be working fine now. If you have any problems shoot me an email at jon@jondrews.com. Thanks!
The new version can be located here: http://www.pixelpost.org/index.php?x...&details=4 |
|
#7
|
|||
|
|||
|
Hello. I installed this modification but it doesn't change the size of my images. Is there something else I need to change in the index before it will work?
You can see what is happening here. edit: wanted to add that I have just resized the images myself, so you can no longer see what is happening at that link. I am wondering if it's something I need to change in the template?
__________________
shana |
|
#8
|
|||
|
|||
|
exif
this mod is somewhat useless if it is not retaining EXIF data. It would be as easy as:
create new.jpg jhead -te original.jpg new.jpg delete original.jpg obviously this would add a requirement, but the jhead binary is only one file, and is installed on a lot of systems already. Plus you could just test to see if it exists or not, and if it doesn't don't retain exif data.. jhead is available at http://www.sentex.net/~mwandel/jhead/ just my .02 |
|
#9
|
|||
|
|||
|
thats awesome! if ya got the time-- go for it! id really love to see this implemented. Im pressed for time lately so i wont be able to do it-- but if you do get it working-- please send me an email. i would love to have this functioning.
|
|
#10
|
|||
|
|||
|
I just updated it to the recent version (1.4.2) it was pretty much just a copy paste. Its working well on my site now.
http://www.pixelpost.org/v1/index.ph...amp;details=64 sidenote: i tried getting hte exif transfer to work with jhead but my server doesnt support exec(). Then i switched over to a library that coppermine uses called phpexifRW but for some reason he says it can write exif data and then in the file itself it says that writing of exif data is temporarily disabled. Do you guys know of another method of transferring the exif data from the original image to the resized image? |
| Post Reply |
| Thread Tools | |
|
|