Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1] 2   Go Down

Author Topic: Resize on upload  (Read 32442 times)

0 Members and 1 Guest are viewing this topic.

mrob

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Resize on upload
« 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
« Last Edit: August 25, 2004, 08:50:59 pm by GauGau »
Logged

RatKing

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 85
    • Personal website
Re: Resize
« Reply #1 on: May 24, 2004, 09:57:39 am »

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.
Logged

mrob

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Resize
« Reply #2 on: May 24, 2004, 01:28:57 pm »

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.
Logged

RatKing

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 85
    • Personal website
Re: Resize
« Reply #3 on: May 26, 2004, 12:59:12 pm »

I'll see what I can do for you over the weekend, should not be to hard to build a little hack for this. :)
Logged

RatKing

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 85
    • Personal website
Re: Resize
« Reply #4 on: May 26, 2004, 10:03:20 pm »

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)

Code: [Select]
                } 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
Code: [Select]
} 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
Code: [Select]
                } 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
Code: [Select]
} 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)
Logged

mrob

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Resize
« Reply #5 on: May 27, 2004, 10:41:15 am »

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.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Resize
« Reply #6 on: May 30, 2004, 09:25:33 pm »

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
Logged

cuteseal

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: Resize
« Reply #7 on: August 12, 2004, 05:14:05 am »

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
Logged

cuteseal

  • Coppermine newbie
  • Offline Offline
  • Posts: 15
Re: [CPG1.3.x]: Resize
« Reply #8 on: August 12, 2004, 08:16:52 am »

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
Logged

lvanderb

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 2
Re: [CPG1.3.x]: Resize
« Reply #9 on: August 23, 2004, 02:08:58 am »

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
Logged

seros

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 85
Re: Resize on upload
« Reply #10 on: September 26, 2004, 06:43:10 pm »

Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Resize on upload
« Reply #11 on: September 26, 2004, 08:47:29 pm »

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
Logged

seros

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 85
Re: Resize on upload
« Reply #12 on: September 30, 2004, 05:47:19 pm »

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 ...
Logged

Medar

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Resize on upload
« Reply #13 on: October 12, 2004, 04:32:22 am »

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.
Logged

Medar

  • Coppermine newbie
  • Offline Offline
  • Posts: 8
Re: Resize on upload
« Reply #14 on: October 12, 2004, 04:47:59 am »

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?
Logged

SimmDogg

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Resize on upload
« Reply #15 on: December 16, 2004, 10:58:02 pm »

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.
Logged

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website
Re: Resize on upload
« Reply #16 on: December 17, 2004, 01:31:40 am »

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.
Logged
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

Tranz

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Female
  • Posts: 6149
Re: Resize on upload
« Reply #17 on: December 17, 2004, 01:44:37 am »

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.
Logged

SimmDogg

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Resize on upload
« Reply #18 on: December 17, 2004, 01:56:03 am »

Quote
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.
« Last Edit: December 17, 2004, 07:30:25 am by GauGau »
Logged

SimmDogg

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Resize on upload
« Reply #19 on: December 17, 2004, 01:59:56 am »

Quote
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?
« Last Edit: December 17, 2004, 07:30:44 am by GauGau »
Logged
Pages: [1] 2   Go Up
 

Page created in 0.047 seconds with 19 queries.