Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
Resize slika??????
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
raytech



Joined: 17 Mar 2004
Posts: 396
Location: Zagreb

PostPosted: 19.06.2004 19:46    Post subject: Resize slika?????? Add user to your forum ignore list Reply with quote

HELP. Ima skriptu za upload podatak koja ima dva dijela

1.upload obrazac
Quote:
<form action="upload.php" method="post" ENCTYPE="multipart/form-data">
<!-- the 'name' field on the input below is very important -->
Izaberite sliku:
<input name="jpgimage" type="file" class="basic" size="30">
<!-- set the max file size -->
<input type="hidden" name="MAX_FILE_SIZE" value="500000">
<!-- submit button -->
<input type="submit" class="basic" value="upload">
<!-- end the form -->
</form>


2. upload
Quote:
<?
//the absolute location of where you want to upload it
//the directory must be chmoded 777
//jpgimage is the name from the top
copy($jpgimage,"assets/slike/$jpgimage_name");
unlink($jpgimage);
?>


Sad kaj bi ja trebao napraviti da mi taj obrazac smanjuje slike na 105 px widtha,
height nije bitnan

Znam da trebam napistai neki function, ali MUUUUUUUUUUUU. My kung fu is weak in the code way.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
smasher



Joined: 10 Jan 2004
Posts: 229
Location: Zaprešić

PostPosted: 19.06.2004 20:06    Post subject: Add user to your forum ignore list Reply with quote

hah, ak oš prikazivat, tj. smanjivat sliku, onda je to lako, al ak oš baš "fizički" smanjit sliju, hmhm, nemam pojma za to, al mislim da je to malo kompliciraniji posao od samo naredbe za to...

nisam baš siguran za što će ti to točno, pa nemrem ni odgovorit baš dobro
a i moraš uzet u obzir da ja tek učim... heh. al rado pomognem ak znam
pa onda reci kaj hoćeš... thumbse radit ili kaj?

_________________
http://3DHR.net - Srce hrvatskih 3d artista
http://www.Rhino3DHelp.com
Back to top
View user's profile Send private message Visit poster's website
silence



Joined: 24 Apr 2004
Posts: 890
Location: .....ni na nebu, ni na zemlji.....

PostPosted: 19.06.2004 20:15    Post subject: Add user to your forum ignore list Reply with quote

hm. ja baš i nisam ljubitelj skripti koje zahtjevaju chmod 777.
možda da potražiš nekaj drugo?

_________________
This End-User License is an agreement between Microsoft Corporation (hereafter referred to as "Microsoft") and you, the end-user (hereafter referred to as "our bitch").
Back to top
View user's profile Send private message Visit poster's website
maxy



Joined: 07 Sep 2003
Posts: 894
Location: Zagreb

PostPosted: 19.06.2004 20:50    Post subject: Add user to your forum ignore list Reply with quote

silence wrote:
hm. ja baš i nisam ljubitelj skripti koje zahtjevaju chmod 777.
možda da potražiš nekaj drugo?


ja sam probo nekidan aplodat u dir koji je imo 775 chmod i nije islo Smile

evo ti komad koda za resizanje, mora radit na svakom serveru sa GD libom:

Code:
function Resize($sourcefile, $destfile, $fw, $fh, $jpegquality = 60)
       {
           list($ow, $oh, $from_type) = getimagesize($sourcefile);
           
           switch($from_type)
           {
               case 1: // GIF
                   $srcImage = imageCreateFromGif($sourcefile);
                   break;
               case 2: // JPG
                   $srcImage = imageCreateFromJpeg($sourcefile);
                   break;
               case 3: // PNG
                   $srcImage = imageCreateFromPng($sourcefile);
                   break;
           }
           
           $tempw = $fw;
           $temph = number_format((($oh*$fw)/$ow), 0);
           
           if($temph < $fh)
           {
               $tempw = number_format((($ow*$fh)/$oh), 0);
               $temph = $fh;
           }
           
           $tempImage = imageCreateTrueColor($tempw, $temph);
           //imageAntiAlias($tempImage, true);
           
           imagecopyresampled($tempImage, $srcImage, 0, 0, 0, 0, $tempw, $temph, $ow, $oh);
           
           // Calculate offsets
           if($temph > $fh)
           {
               $offsety = number_format(($temph/2)-($fh/2), 0);
               $offsetx = 0;
           }
           else
           {
               $offsety = 0;
               $offsetx = number_format(($tempw/2)-($fw/2), 0);
           }
           
           $destImage = imageCreateTrueColor($fw, $fh);
           
           imagecopyresampled($destImage, $tempImage, 0, 0, $offsetx, $offsety, $fw, $fh, $fw, $fh);
           
           imageJpeg($destImage, $destfile, $jpegquality);
           
       }


kak radis sa tim:

recimo aplodas neku sliku i oces sad da ti bude dimenzija 60x60 i da stoji u direktoriju /assets/slike

Resize($_FILES['file']['tmp_name'], '/assets/slike/'.$_FILES['file']['name'], 60, 60);

i bok.

ak ti nest nije jasno, vici.
Back to top
View user's profile Send private message
silence



Joined: 24 Apr 2004
Posts: 890
Location: .....ni na nebu, ni na zemlji.....

PostPosted: 19.06.2004 21:09    Post subject: Add user to your forum ignore list Reply with quote

maxy wrote:
silence wrote:
hm. ja baš i nisam ljubitelj skripti koje zahtjevaju chmod 777.
možda da potražiš nekaj drugo?


ja sam probo nekidan aplodat u dir koji je imo 775 chmod i nije islo Smile

.


sjećaš se onog mog koda za upload, di sam iz tempa prebacivao u konačni direktorij s FTPom?...kaj misliš zakaj sam to pisao Wink
možda nije najelegantnije rješenje, ali onda ti direktorij ne mora biti 777

_________________
This End-User License is an agreement between Microsoft Corporation (hereafter referred to as "Microsoft") and you, the end-user (hereafter referred to as "our bitch").
Back to top
View user's profile Send private message Visit poster's website
maxy



Joined: 07 Sep 2003
Posts: 894
Location: Zagreb

PostPosted: 19.06.2004 21:24    Post subject: Add user to your forum ignore list Reply with quote

a gle, ak si tolki paranoik onda napravi aplod skriptu koja chmoda dir na 777 pa mu poslje uploada stavi chmod 775 ili koji vec i mirna bosna Very Happy
Back to top
View user's profile Send private message
silence



Joined: 24 Apr 2004
Posts: 890
Location: .....ni na nebu, ni na zemlji.....

PostPosted: 19.06.2004 21:35    Post subject: Add user to your forum ignore list Reply with quote

maxy wrote:
a gle, ak si tolki paranoik onda napravi aplod skriptu koja chmoda dir na 777 pa mu poslje uploada stavi chmod 775 ili koji vec i mirna bosna Very Happy


ma LOL. nisam baš tolki paranoik. Very Happy
ustvari između paranoje i ljenosti uvijek biram ljenost, tak da nema šanse da idem sad novu skriptu pisat....ono kaj imam radi i radi zadovoljavajuće....još samo da puknem resize unutra i to bi bilo to (ali sam ljen, pa će resize pričekat)...

Laughing

_________________
This End-User License is an agreement between Microsoft Corporation (hereafter referred to as "Microsoft") and you, the end-user (hereafter referred to as "our bitch").
Back to top
View user's profile Send private message Visit poster's website
raytech



Joined: 17 Mar 2004
Posts: 396
Location: Zagreb

PostPosted: 19.06.2004 22:02    Post subject: Vićem Add user to your forum ignore list Reply with quote

AAAAAAAAAAAAAAAAAAAA

@ maxy: O.k ajmo koda razgovarš s policajcem(inteligence wise)
znaći moram imati dva file. jedan function.php i drugi obrazac php.

Jel se to može inegrati u onaj kod gore. Stvarno sam tek početnik u php.

Što sad ide u ono malo više što si napisao to je funkcija, a što mi treba za obrazac. Mislim što trebam integrati u ono formu da se to poveže, i dali mi treba još onaj upload.php????

E da želim da se slikca ima constrain proprtions, tj samo mi treba smanjit image 105 px širine, a height je nedefiniran.

Sorry glup sam znam ali jebiga, volio bih debelo ući u kod ali nikao da nađem vremena.

@samsher: Evo vidi što radim http://www.kunkera.hr/hvs username: HVS, password:hvs
Back to top
View user's profile Send private message Send e-mail MSN Messenger
t3r0



Joined: 08 Jun 2004
Posts: 107

PostPosted: 20.06.2004 00:31    Post subject: Re: Vićem Add user to your forum ignore list Reply with quote

raytech wrote:
AAAAAAAAAAAAAAAAAAAA

@ maxy: O.k ajmo koda razgovarš s policajcem(inteligence wise)
znaći moram imati dva file. jedan function.php i drugi obrazac php.

Jel se to može inegrati u onaj kod gore. Stvarno sam tek početnik u php.


ne moras imati 2 fajla, samo dodas ovu funkciju sto je maxy napisao u taj fajl koji prima podatke (sliku).
I onda pozoves funkciju kao sto je maxy napisao:
Resize($_FILES['file']['tmp_name'], '/assets/slike/'.$_FILES['file']['name'], 60, 60);

raytech wrote:
Što sad ide u ono malo više što si napisao to je funkcija, a što mi treba za obrazac. Mislim što trebam integrati u ono formu da se to poveže, i dali mi treba još onaj upload.php????


u obrazac ne moras nista dodati jer ce nakon uploada funkcija napraviti thumbnail i spremiti ga tamo gdje joj kazes.
Back to top
View user's profile Send private message
silence



Joined: 24 Apr 2004
Posts: 890
Location: .....ni na nebu, ni na zemlji.....

PostPosted: 20.06.2004 07:34    Post subject: Re: Vićem Add user to your forum ignore list Reply with quote

raytech wrote:

E da želim da se slikca ima constrain proprtions, tj samo mi treba smanjit image 105 px širine, a height je nedefiniran.


kolko sam skužio recimo imaš dvije slike...jednu 105x140 i drugu 100x100 i na kraju onje trebaju stati u prostor 60x60?

nakon uploada možeš dobiti veličinu slike pomoću
getimagesize() funkcije koja vraća array gdje je [0] širina, a [1] visina.
zatim bi trebo stavit tri uvijeta širina>visina, širina == visina, širina < visina i prema njima izračunat nove dimenzije.

tek sam se probudio, pa ak sam nekaj fulo nek me maxy ispravi Smile

_________________
This End-User License is an agreement between Microsoft Corporation (hereafter referred to as "Microsoft") and you, the end-user (hereafter referred to as "our bitch").
Back to top
View user's profile Send private message Visit poster's website
maxy



Joined: 07 Sep 2003
Posts: 894
Location: Zagreb

PostPosted: 20.06.2004 08:37    Post subject: Add user to your forum ignore list Reply with quote

// upload php

function Resize($sourcefile, $destfile, $fw, $fh, $jpegquality = 60)
{
list($ow, $oh, $from_type) = getimagesize($sourcefile);

switch($from_type)
{
case 1: // GIF
$srcImage = imageCreateFromGif($sourcefile);
break;
case 2: // JPG
$srcImage = imageCreateFromJpeg($sourcefile);
break;
case 3: // PNG
$srcImage = imageCreateFromPng($sourcefile);
break;
}

$tempw = $fw;
$temph = number_format((($oh*$fw)/$ow), 0);

if($temph < $fh)
{
$tempw = number_format((($ow*$fh)/$oh), 0);
$temph = $fh;
}

$tempImage = imageCreateTrueColor($tempw, $temph);
//imageAntiAlias($tempImage, true);

imagecopyresampled($tempImage, $srcImage, 0, 0, 0, 0, $tempw, $temph, $ow, $oh);

// Calculate offsets
if($temph > $fh)
{
$offsety = number_format(($temph/2)-($fh/2), 0);
$offsetx = 0;
}
else
{
$offsety = 0;
$offsetx = number_format(($tempw/2)-($fw/2), 0);
}

$destImage = imageCreateTrueColor($fw, $fh);

imagecopyresampled($destImage, $tempImage, 0, 0, $offsetx, $offsety, $fw, $fh, $fw, $fh);

imageJpeg($destImage, $destfile, $jpegquality);

}

list($height, $width) = @getimagesize($_FILES['jpgimage']['tmp_name'];

// idemo sad smanjit sliku na 105 pix

if($width > 105)
{
$ratio = round($width/105);

$width = 105;
$height = floor($height/$ratio);
}

// gdje oces spremit sliku?

$destination_directory = '/assets/slike/'.$_FILES['jpgimage']['name'];

// pozovi funkciju da sejvas fajlove

Resize($_FILES['jpgimage']['tmp_name'], $destination_directory, $width, $height);
Back to top
View user's profile Send private message
raytech



Joined: 17 Mar 2004
Posts: 396
Location: Zagreb

PostPosted: 20.06.2004 09:29    Post subject: Kralj SI Add user to your forum ignore list Reply with quote

@MAXY.
Respect

Javalja mi grešku u ovom redu, što znači da mi GD ni je uključen I THiNK.
Kak se uključuje GD????????
list($height, $width) = @getimagesize($_FILES['jpgimage']['tmp_name'];
Back to top
View user's profile Send private message Send e-mail MSN Messenger
maxy



Joined: 07 Sep 2003
Posts: 894
Location: Zagreb

PostPosted: 20.06.2004 09:59    Post subject: Add user to your forum ignore list Reply with quote

napisi koju ti gresku tocno prijavi...
Back to top
View user's profile Send private message
maxy



Joined: 07 Sep 2003
Posts: 894
Location: Zagreb

PostPosted: 20.06.2004 10:02    Post subject: Add user to your forum ignore list Reply with quote

eto sto se dogodi kad ides samo kopipejstat Smile
imam sytax error pa ti evo ispravljen komad koda:

list($height, $width) = @getimagesize($_FILES['jpgimage']['tmp_name']);
Back to top
View user's profile Send private message
raytech



Joined: 17 Mar 2004
Posts: 396
Location: Zagreb

PostPosted: 20.06.2004 10:43    Post subject: Sad mi je već neugodno Add user to your forum ignore list Reply with quote

Sad mi je već neugodno

Za ovaj red(12)
Quote:

$srcImage = imageCreateFromJpeg($sourcefile);
break;

veli ovo
Quote:
Fatal error: Call to undefined function: imagecreatefromjpeg() in c:\apache\htdocs\hvs\upload.php on line 12


E da, ja još uvjek pozivam taj upload php, iz obrazca.php, a ak bi napravio formu u upload.php kak onda pozovem funkciju "resize".

Da ovaj dio prebacim u upload.php

Quote:
<form action="upload.php" method="post" ENCTYPE="multipart/form-data">
<!-- the 'name' field on the input below is very important -->
Izaberite sliku:
<input name="jpgimage" type="file" class="basic"
size="30">
<!-- set the max file size -->
<input type="hidden" name="MAX_FILE_SIZE" value="500000">
<!-- submit button -->
<input type="submit" class="basic" value="upload">
<!-- end the form -->
</form></td>


jel moram promjenit ovo
Quote:
form action="upload.php"
u nešto?
Back to top
View user's profile Send private message Send e-mail MSN Messenger
maxy



Joined: 07 Sep 2003
Posts: 894
Location: Zagreb

PostPosted: 20.06.2004 12:23    Post subject: Add user to your forum ignore list Reply with quote

za ovu gresku koju ti javlja - to znaci da nemas GD library instaliran kod sebe na kompu. stoga trebas to testirati na nekom serveru koji to ima instalirano.

ovu funkciju trebas strpati negdje u file koji obradjuje podatke iz formulara.
Back to top
View user's profile Send private message
Phiber



Joined: 18 Apr 2004
Posts: 319
Location: Čakovec, Kroejša

PostPosted: 20.06.2004 12:45    Post subject: Add user to your forum ignore list Reply with quote

imajte na umu da GD verzije 2 na dalje ne podrzava gif. (negde sam bio procitao).

_________________
- Xatrix Security news portal -- redizajn napravljen, al radim css Smile
- - TIP / Rapid IT : web design & hosting -- za ovog ne, taj je u ladici Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
_butch



Joined: 10 Sep 2003
Posts: 870
Location: Maichno, Krlovc

PostPosted: 20.06.2004 13:16    Post subject: Add user to your forum ignore list Reply with quote

posto je istekao patent na gif, php 4.3.7 ga sada podrzava, pa se sve moze raditi Smile

_________________
FRENCH GUARD: No chance, English bed-wetting types.
I burst my pimples at you and call your door-opening request a silly thing, you tiny-brained wipers of other people's bottoms!
Flikrac
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
raytech



Joined: 17 Mar 2004
Posts: 396
Location: Zagreb

PostPosted: 20.06.2004 14:02    Post subject: DA Add user to your forum ignore list Reply with quote

ali meni ne radi jer nemam pojma gdje treba ugurat onu funkciju.
Good damn PHP.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
silence



Joined: 24 Apr 2004
Posts: 890
Location: .....ni na nebu, ni na zemlji.....

PostPosted: 20.06.2004 14:06    Post subject: Add user to your forum ignore list Reply with quote

funkciju za mjenjanje veličine?
pa nakon što se datoteka uploada Wink

dakle, negdje u upload.php ako se ne varam.....

_________________
This End-User License is an agreement between Microsoft Corporation (hereafter referred to as "Microsoft") and you, the end-user (hereafter referred to as "our bitch").
Back to top
View user's profile Send private message Visit poster's website
maxy



Joined: 07 Sep 2003
Posts: 894
Location: Zagreb

PostPosted: 20.06.2004 14:28    Post subject: Re: DA Add user to your forum ignore list Reply with quote

raytech wrote:
ali meni ne radi jer nemam pojma gdje treba ugurat onu funkciju.
Good damn PHP.


pa u jebeni file koji ti je naveden kao target formulara

isuse, zivce ces mi popit!
Back to top
View user's profile Send private message
raytech



Joined: 17 Mar 2004
Posts: 396
Location: Zagreb

PostPosted: 20.06.2004 14:31    Post subject: Add user to your forum ignore list Reply with quote

Quote:
isuse, zivce ces mi popit!
Confused

sorry dude, Embarassed

Ali radi sad, jejejejejejejejejejejejejejejeje. Sorry moj mozak radi tako da komplicira di netreba.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
maxy



Joined: 07 Sep 2003
Posts: 894
Location: Zagreb

PostPosted: 20.06.2004 18:53    Post subject: Add user to your forum ignore list Reply with quote

i bolje ti je da radi Very Happy
Back to top
View user's profile Send private message
Tomica



Joined: 16 May 2004
Posts: 39
Location: Novi Marof, CRO

PostPosted: 26.06.2004 23:59    Post subject: Add user to your forum ignore list Reply with quote

.. a da sad ja malo zakompliciram! Embarassed Dal netko zna kak sve to napraviti bez GD-a?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
t3r0



Joined: 08 Jun 2004
Posts: 107

PostPosted: 27.06.2004 00:42    Post subject: Add user to your forum ignore list Reply with quote

Prosurfaj malo po sljedećim linkovima:

ImageMagick http://www.imagemagick.org
NetPBM http://netpbm.sourceforge.net
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group