forum.coppermine-gallery.net
No Support => Modifications/Add-Ons/Hacks => Mods: Watermarking & image manipulation => Topic started by: mrob on May 24, 2004, 04:22:20 am
-
I'd like to limit the size of uploaded files, but not reject those that are too large. Instead, I'd like to have the image resized if it's too large. In effect, I'd like to just have the thumbnail and intermediate files, but not the original. Is this possible?
Thanks,
Mike
-
That should be posible but for one slight problem... Files are usualy limted to 1024Kb upload to prevent DoS atacs on servers and so on. Other than that a long upload might result in a timeout of the webbrowser again a problem.
If all the problems above are not an issue and you are not worried about all the security problems that the upload of big files brings with it, it should be quite easy to create this fix for this. Personlay I would say don't just srink the image on your computer before upload or upload the via FTP.
-
Thanks for the reply. I wouldn't have a problem with having a file rejected on file size. But for those that are accepted, I would like to have resized based on the maximum image dimension.
-
I'll see what I can do for you over the weekend, should not be to hard to build a little hack for this. :)
-
Ok, I don;t have a life I know but the solution to this problem I do have...
The upload.php file needs a little change to get this working.
The following two parts need to be corrected (this is CPG1.3)
} elseif (max($imginfo[0], $imginfo[1]) > $CONFIG['max_upl_width_height']) {
@unlink($path_to_image);
// The file upload has failed -- the image dimensions exceed the allowed amount.
$file_failure_array[] = array( 'failure_ordinal'=>$failure_ordinal, 'file_name'=> $file_name, 'error_code'
=>$lang_upload_php['pixel_allowance']);
// There is no need for further tests or action, so skip the remainder of the iteration.
continue;
}
with} elseif (max($imginfo[0], $imginfo[1]) > $CONFIG['max_upl_width_height']) {
// RatKing's hack to resize images that are 'to big' according to the admin
// Determain which is the tallest width or height.
if ( $imginfo[0] > $imginfo[1] ) { $tall = 'wd'; } else { $tall = 'ht'; }
// Simply resize the image to the biggest file size that is allowed.
resize_image($path_to_image, $path_to_image, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $tall);
// Should be all there is to it Now when I upload a very big file it will be squashed
// nothing more to do we can just escape this if loop and process the image
continue;
}
and
} elseif (max($imginfo[0], $imginfo[1]) > $CONFIG['max_upl_width_height']) {
@unlink($path_to_image);
// The file upload has failed -- the image dimensions exceed the allowed amount.
$URI_failure_array[] = array( 'failure_ordinal'=>$failure_ordinal, 'URI_name'=> $_POST['URI_array'][$count
er], 'error_code'=>$lang_upload_php['pixel_allowance']);
// There is no need for further tests or action, so skip the remainder of the iteration.
continue;
}
with} elseif (max($imginfo[0], $imginfo[1]) > $CONFIG['max_upl_width_height']) {
// RatKing's hack to resize images that are 'to big' according to the admin
// Determain which is the tallest width or height.
if ( $imginfo[0] > $imginfo[1] ) { $tall = 'wd'; } else { $tall = 'ht'; }
// Simply resize the image to the biggest file size that is allowed.
resize_image($path_to_image, $path_to_image, $CONFIG['max_upl_width_height'], $CONFIG['thumb_method'], $tall);
// Should be all there is to it Now when I upload a very big file it will be squashed
// nothing more to do we can just escape this if loop and process the image
continue;
}
}
In my "development/mess about" version of CPG1.3 I have also made a change to the config page and the english language file so I can enable and disable this function on the config page.
I have not posted that code here but if you want I could send the modified files to you. np...
I am not sure if this will work in CPG1.2 I think it will but I have not tested this yet (to little time to test that for now)
-
Wow, thanks for the quick effort! I'll give it a try when I get a chance. No need to send me the other changes...I would always keep this feature enabled. I'll let you know how it goes.
-
I have not posted that code here but if you want I could send the modified files to you. np...
I would like to have a look, could you post your "full hack" for cpg1.3.0?
Thanks
GauGau
-
Hi,
Nice mod/hack! It wasn't working for me (i'm using 1.3.1) but noticed that if you comment out the "continue;" statements, then it works like a charm!!
I think there's some code at the end of each iteration to add successful files to an array. The continue statements were skipping those.
Cheers,
Julian
-
Ooh, I just noticed that on resized images, the EXIF data is lost! :(
If I resize beforehand and upload, then the data is retained.
Any ideas how this can be fixed?
Thanks,
Jules
-
Hi,
I just posted a hack on how to resize originals, after which, of course, I found RatKing's mod!
Then I also noticed that my EXIF info was being lost too... at any rate, I figured out how to save it when resizing originals and it's posted with my resize original hack, at the bottom...
http://forum.coppermine-gallery.net/index.php?topic=9159.0
Linda
-
Does it work with this MOD? http://forum.coppermine-gallery.net/index.php?topic=9578.msg42951#msg42951
-
why don't you find this out for us ::)? How are we to know? All we can do is try this as well. Just backup your files, so you can savely go back.
Joachim
-
So i have tried and and replaced the "$CONFIG['max_upl_width_height']" with "$USER_DATA['group_max_upl_width_height']" but it doesn't work yet I'm trying ...
-
This would be incredible to have as an option in the Config. Why you say? Those people who have potentially limited webspace (or bandwidth), but have 6 megapixel cameras taking 1.2 meg images!
Working to add it right now. Getting the "Error Message - Exceeded filesize permitted by CPG." right now, so trying to figure out why it is giving me this after the hack.
-
Yep, I cannot get past the error. I have the code correct (I did not comment out the CONTINUE statement like cuteseal did, I tried and it still did nothing).
I am using CPG1.32 - this should work in 1.32, correct?
-
Why doesn't someone post the corrected files. I have made some changes to the files referenced but nothing is working. I think this is part to too many people trying to put their 2 cents in. If you know what you are doing, post the files somewhere so we can download them. Referencing line #'s and yada yada don't work. Just post the files.
-
The devel version has resizing during uploads. You'll have to wait for 1.4 to be released to see it, since I'm the one who did the coding for the devel version and I'm not reverse engineering the code to work with a soon-to-be outdated version.
-
Why doesn't someone post the corrected files. I have made some changes to the files referenced but nothing is working. I think this is part to too many people trying to put their 2 cents in. If you know what you are doing, post the files somewhere so we can download them. Referencing line #'s and yada yada don't work. Just post the files.
Someone already put in the time and effort to come up with the mod and to post it. If you're too lazy to apply the changes yourself, don't use it. Maybe the person was using a modded file. There's no point in you using their already modified modded file.
-
Someone already put in the time and effort to come up with the mod and to post it. If you're too lazy to apply the changes yourself, don't use it. Maybe the person was using a modded file. There's no point in you using their already modified modded file.
I have already tried using the modded files. I have tried to apply the changes to the original dev files. Nothing has worked. I'm not lazy. I 've worked with these changes about 6-10 times and none of what I have tried(from post to this board) have worked.
-
Someone already put in the time and effort to come up with the mod and to post it. If you're too lazy to apply the changes yourself, don't use it. Maybe the person was using a modded file. There's no point in you using their already modified modded file.
I have tried using this download and I am still getting errors.
"cpg1.3.0_mod_limit_files.zip"
Is this the correct download?
-
http://prdownloads.sourceforge.net/coppermine/cpg1.3.0_mod_limit_files.zip?download (zip)
or
http://prdownloads.sourceforge.net/coppermine/cpg1.3.0_mod_limit_files.tar?download (tar)
Joachim
-
That's the download I am using but it doesn't work for me. Does it matter what the gallery directory is called? What could be the problem? Any ideas?
-
Can I get a little help with this Resize on upload mod? I have tried to edit existing files as shown and instructed in these forums and I have installed the cpg1.3.0_mod_limit_files.zip. Neither has worked. Any help would appreciated.
-
Precise of a Hack for version 1.4x that redimensione the images in the upload and if possible it lowers the quality of the image
Thanks
-
Don't ask for other versions (http://forum.coppermine-gallery.net/index.php?topic=24540.0)