When FCK config for size images?
#1
Posted 02 November 2006 - 07:30 PM
Is it possible config images size for users.
Example
max size 500x300 px and 30kb.
Thx for help
#2
Posted 02 November 2006 - 10:35 PM
#3
Posted 12 June 2008 - 06:45 AM
Ted
#4
Posted 12 June 2008 - 07:40 PM
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..
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
Posted 12 June 2008 - 09:14 PM
#6
Posted 13 June 2008 - 06:14 AM
I'll have to translates the commets, as they are in Dutch..
Edited by Ed Headset, 13 June 2008 - 06:14 AM.
#7
Posted 13 June 2008 - 09:25 AM
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
Posted 13 June 2008 - 08:02 PM
Ted Donkers, on Jun 13 2008, 11:25 AM, said:
Alkmaar, Holland
Forum language is English so..... it's your decision...
So I'll add some translation to it, so everyone can read the comments
Ted Donkers, on Jun 13 2008, 11:25 AM, said:
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
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
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
Posted 15 June 2008 - 02:25 PM
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
Posted 15 June 2008 - 02:51 PM
#11
Posted 16 June 2008 - 07:07 AM
Ted Donkers, on Jun 15 2008, 04:25 PM, said:
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
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.
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











