1
sceilig
Uploading and resizing images
  • 2006/4/22 23:02

  • sceilig

  • Just popping in

  • Posts: 53

  • Since: 2006/3/1 1


In creating some modules and hacking others, I wanted to come up with a standard solution for allowing users to upload photos,have them resized along the way and then store the photos in a user's image folder (a subfolder of uploads that gets created when they try and upload a photo).

I see that there is the XoopsMediaUploader class to upload images, but it seems you specify the max width and max height of what an uploaded image should be, and not what the end result resized max width and height should be.

Essentially I am more concerned about the end result - that an image should be say 100px wide by 100px high - the user can upload whatever size image they want but it will be resized to fit those proportions before saving or displaying.

Am I wrong in thinking the XoopsMediaUploader cant do what I would like it to do. Perhaps there is anoher XOOPS resize function out there, or do I just have to create a custom bit of code myself - I figured a lot of other people would also run into this problem.

I also dont want to use the imagemanager or the imanager plugin with one of the html editors - just a simple file upload box on a form.

2
3lr0n
Re: Uploading and resizing images
  • 2006/8/4 12:52

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


Hi.. im looking for the same, but for a certain module only, did you find the answer?

ta in advance
Spanish Overclocking Community xoops based site : www.overclocking.es

3
Will_H
Re: Uploading and resizing images
  • 2006/8/4 13:04

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


Ah the age old question of using imagemagick or gd to create thumbnails through XOOPS. To this day mine still doesnt work properly. So if you find a solution it would be an aid to the entire community. Especially a solution that would be universal across all modules. A core hack that would ensure resizing of images posted in news, forums, and blocks would be ideal.

Good Luck.

4
zoullou
Re: Uploading and resizing images
  • 2006/8/4 13:18

  • zoullou

  • Quite a regular

  • Posts: 250

  • Since: 2004/3/2 0


Here is a good "framework" to work with image : PEAR::Image_Transform

Cheers

5
Djiman
Re: Uploading and resizing images
  • 2006/8/4 13:27

  • Djiman

  • Just popping in

  • Posts: 91

  • Since: 2006/7/26


There are some nice 'upload script ' to upload images scattered over the net - some are easy to use to incorporate - some are safer than others.
[edit]
the above example is interesting
you may also use this one an example to find even more deeper::http://www.maaking.com/

6
3lr0n
Re: Uploading and resizing images
  • 2006/8/4 14:39

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


Lol, ta for the answer but i dont have any code aptitudes to do this lol :P

btw.. with the uploader.. can i use an url instead of a local file?, can someone put an url in the box and upload it to my server?

ta in advance
Spanish Overclocking Community xoops based site : www.overclocking.es

7
sceilig
Re: Uploading and resizing images
  • 2006/8/4 15:39

  • sceilig

  • Just popping in

  • Posts: 53

  • Since: 2006/3/1 1


I did actually create a hack to handle image resizing - i added a function called XoopsMakeThumbnail() to the class/uploader.php file

A rough implementation of it would be this:
include_once XOOPS_ROOT_PATH "/class/uploader.php";
$allowed_mimetypes = array('image/gif''image/jpeg''image/pjpeg''image/x-png');
$uploader = new XoopsMediaUploader($persdir$allowed_mimetypes$maxfilesize$maxfilewidth$maxfileheight);
if (
$uploader->fetchMedia('foto')) {
   if (!
$uploader->XoopsMakeThumbnail()) {
       
$output_str .= $uploader->getErrors();
   } else {      
       
$foto $uploader->savedFileName;
   }   
} else {
   
$output_str .= $uploader->getErrors();
}


My function calculates how much to resize the image so that it is reduced to either the maxwidth or maxheight. Then since I use imagemagick, I resize the image that way.

However, i never published the hack and wouldnt until it was streamlined with having more parameters (choosing GD, netpbm or imagemagick and their paths). And whoever was to use would need to know their way around xoops.

Alternatively, you could use the imanager or ibrowser plugins with a html editor module like TinyEditor - you can upload a photo and specify a number of different resizes to be made from it.

Login

Who's Online

257 user(s) are online (195 user(s) are browsing Support Forums)


Members: 0


Guests: 257


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits