Jump to content


When FCK config for size images?


10 replies to this topic

#1 zakopiec

    Etomite Forum Newbie

  • Member
  • 7 posts

Posted 02 November 2006 - 07:30 PM

Hi
Is it possible config images size for users.
Example
max size 500x300 px and 30kb.
Thx for help

#2 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 02 November 2006 - 10:35 PM

For uploads I think that is left to the site administrator to handle rather than being a configuration option within FCKeditor... Upload limits can be set either in your .htaccess file or via PHP's ini_set()... I have never seen pixel size limits as being an option as the file would need to be uploaded before any such determination could possibly be made anyway...

#3 TedD

    Etomite Forum Newbie

  • Member
  • 34 posts

Posted 12 June 2008 - 06:45 AM

In CKFinder (CKFinder is a powerful and easy to use Ajax file manager for web browsers) it's possible to resize images. CKFinder is very easy to integrate with FCKeditor and Etomite 1.1

Ted

#4 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 12 June 2008 - 07:40 PM

I know I have something to do that.
It's a image uploader, I've made sometime ago, it isn't finished, but functional, I think..

What it does(this is from my memory, so I could be totally wrong here.. :blush: )
it checks the image upload for size, and if size is OK it save it to a temporary folder.
Then it adjusts it to the maximum size if the image dimensions are bigger,
and transfers the converted image to the destination folder.
It then deletes the original uploaded file.

That's it, I think.
So the uploaded image is converted to the preset dimensions, or smaller.

I have the source somewhere, It worked under PHP 4.
I don't know if it does with PHP 5.

If you like to see the source, I'll have a look in the big dusty archive or lost code's ;)

Edited by Ed Headset, 13 June 2008 - 06:12 AM.


#5 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 12 June 2008 - 09:14 PM

I also have a piece of code that I use for resizing images all the time... Not sure what the exact need here is, but if the code is needed I can try to post a generic version here... I also use another version of it to save a thumb and a resized image...

#6 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 13 June 2008 - 06:14 AM

I'll see if I can post it here, so you can see how I've done it.

I'll have to translates the commets, as they are in Dutch.. B)

Edited by Ed Headset, 13 June 2008 - 06:14 AM.


#7 TedD

    Etomite Forum Newbie

  • Member
  • 34 posts

Posted 13 June 2008 - 09:25 AM

For me it isn't necessary to translate from Dutch to English because I'm a Dutch CHEESEHEAD :blush: (from Alkmaar)
Alkmaar, Holland
Forum language is English so..... it's your decision...

I'm curious what your solutions are. Is the quality (for example 90% *.jpg) also adjustable ?
With CKFinder you can change the quality in %s of images and thumbnails when you upload an image.
Licence for a single website $ 59,- and Licenses CKFinder to be used inside pages of all web sites owned or produced by me $ 590,- To expensive for me

Kind regards
Ted

Edited by Ted Donkers, 13 June 2008 - 09:25 AM.


#8 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 13 June 2008 - 08:02 PM

View PostTed Donkers, on Jun 13 2008, 11:25 AM, said:

For me it isn't necessary to translate from Dutch to English because I'm a Dutch CHEESEHEAD :blush: (from Alkmaar)
Alkmaar, Holland
Forum language is English so..... it's your decision...
I know you are a fellow countryman ;) but this forum has English as it's main language.
So I'll add some translation to it, so everyone can read the comments :D

View PostTed Donkers, on Jun 13 2008, 11:25 AM, said:

I'm curious what your solutions are. Is the quality (for example 90% *.jpg) also adjustable ?
With CKFinder you can change the quality in %s of images and thumbnails when you upload an image.
Licence for a single website $ 59,- and Licenses CKFinder to be used inside pages of all web sites owned or produced by me $ 590,- To expensive for me

Kind regards
Ted
Hmm I'm not sure what you mean, but I think so.
As this is a very old one <* blowing the dust of*>
It worked, but maybe it's not usable, but might give you an idea ;)

Thinking back I realise it's maybe not very well set up/programmed.
As I recall this might be of my first projects in PHP 4.0 :blush:


Here's the code:
[Edit]
Code has been updated!
[/edit]

<?php
/** PHP Images uploader
version 0.5 Wm (Working Model)
Copyright 2001 Eduard Frankes.


Originally in Dutch but to make it better readable for this post
English Translations are added as comments


**/

if (isset($_FILES['bestand'])) {

//de variabellen
$maxsize = 302400; //maximale grote in bytes (max size in bytes)
$file_name = "image"; //naam van de foto (name of file)
$map = "bestanden/"; //mapnaam. Vergeet de / niet op het einde (folder  / don't forget "/"at end)

//De groote van het bestand vergelijken met het maximum toegelaten
//(size of file compair with max size)
if ($_FILES['bestand']['type'] > $maxsize){
exit("Je bestand " . $_FILES['bestand']['size'] . " bytes, het maximum toegelaten is " . $maxsize . " bytes");
} 

//checken of het wel een jpg is (Is it a JPEG ?)
if($_FILES['bestand']['type'] == "image/pjpeg") {

//de extensie van het bestand in een variabelle gooien (add ext into variable)
$x = strtolower(substr($_FILES['bestand']['name'], -3));

$n = 0;
// Check of het plaatje al bestaat, zo ja, filename verhogen (check if file exist, if so add 1 to filename)
while (file_exists($map . $file_name . $n . '.' . $x)) 
{ 
$n = $n + 1; 
} 
$file_name = $file_name . $n; 

//het bestand verplaatsen naar de opgegeven map en hernoemen naar de opgegeven filenaam 
//( move file to destination folder and rename to new filename)
move_uploaded_file($_FILES['bestand']['tmp_name'],$map . $file_name . '.' . $x);
//bestand chmodden(is alleen van belang voor linux webserver)

$width = 100; //maximale breedte, in pixels, van de thumbnail (max thumbnail width in pixels)
$thumb = "bestanden/thumbs/" . $file_name . '.' . $x;
//de map waar de thumbnails in komen(alleen tussen de quotes veranderen) 
//($thumb  = folder for thumbnails)
$orig = $map . $file_name . '.' . $x;
//het plaatje gaan verkleinen resize image
$b = imagecreatefromjpeg($map . $file_name . '.' . $x) or die ("Jpg probleempje");
$bx = imagesx($b); //breedte van het orgineel (width original)
$by = imagesy($b); //hoogte van het orgineel (height original)
$lm = $b;
//hoogte uit rekennen (calculation)
$temp=$bx/$width;
$height=$by/$temp;
//het plaatje gaan maken (make image)
$lm1 = imagecreate($width ,$height) or die ("Probleem met maken van plaatje");
//als je geen GD library 2 hebt moet je imagecopyresampled veranderen in imagecopyresized(lagere kwaliteit)
// if you don't have GD library change line below in imagecopyresized, but this has a  lower quality)
imagecopyresampled($lm1, $lm, 0, 0, 0, 0, $width, $height, $bx, $by);
//80 is jpg kwaliteit maar je kan ook tot 120 gaan of lager dan 80
//80 is JPG quality but you can also use 120 or lower as 80)
Imagejpeg($lm1,$thumb,80);
//de troep opruimen (flush garbage)
imageDestroy($lm1);
imageDestroy($lm);
echo "Het plaatje is succesvol opgeslagen"; // image save successfully
//error printen als het geen jpg is // display error if not JPG
} else {
echo "Het bestands formaat word niet ondersteund.<br> Alleen jpg word toegelaten.";
}
} else {
echo "Kies een plaatje (alleen jpg)."; // give image JPG only
}
?>
<form action="" enctype="multipart/form-data" method="post">
<input type="file" name="bestand">
<input type="submit" name="submit" value="Upload">
</form>

Edited by Ed Headset, 16 June 2008 - 07:23 AM.


#9 TedD

    Etomite Forum Newbie

  • Member
  • 34 posts

Posted 15 June 2008 - 02:25 PM

Hi Ed,

I tried your script and it didn't work. For the time being I'm using CKFinder.
A lot of us, open source CMS users, are searching for the perfect on-line image editor and editor.

Thanks a lot
Ted

#10 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 15 June 2008 - 02:51 PM

The Advanced Image Manager in the newest release of Xinha works quite well and can probably be integrated into other editors... It allows resizing, cropping, saving in alternate formats, etc... The version in older releases isn't bad either but the newest one has more features...

#11 Ed Headset

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 194 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Etomite, PHP, Ajax.
    3D imaging

Posted 16 June 2008 - 07:07 AM

View PostTed Donkers, on Jun 15 2008, 04:25 PM, said:

Hi Ed,

I tried your script and it didn't work. For the time being I'm using CKFinder.
A lot of us, open source CMS users, are searching for the perfect on-line image editor and editor.

Thanks a lot
Ted

No Problem Ted,

But I was afraid it didn't work anymore.

I'll have a go at it, see if I can get something out of it ;)

[edit]
Just checked it out, locally on my Wampserver, and it does work!

To get it working you need to do the following:

On line 1 change "<?" in to "<?php"
Yes I used to use short tags :blush:

secondly create a folder where the source is, and call this one "bestanden" open rhis folder
and create a "thumbs" folder, and it should work.

The upload is stored in "bestanden" and the thumbnail is stored in "thumbs"

Images are renamed to image##.jpg and so are the Thumbnails.

This even works with PHP 5.2.6.
:D

BTW: I've updated the code, I've found some errors in the translation, and I've added php to the <? tag ;)
[/edit]

Edited by Ed Headset, 16 June 2008 - 07:25 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users