הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

 
 
כלים לאשכול תצורת הצגה
Prev הודעה קודמת   הודעה הבאה Next
ישן 20-02-06, 20:45   # 1
-roee-
חבר על
 
מיני פרופיל
תאריך הצטרפות: Nov 2005
מיקום: IL
הודעות: 864

-roee- לא מחובר  

כתבתי קוד ב PHP לשינוי גודל של תמונה, בחינם לשימוש

שלום,
לאחר שלא הייתי פעיל פה הרבה זמן יחסית החלטתי לבנות איזה משהו קטן כזה לפורום...
אני בניתי קוד שעובד על משתנים ב GET.
על מנת להשתמש עושים ככה בכתובת:
image.php?i=http://www.hosts.co.il/forums/images/misc/vbulletin3_logo_white.gif&width=400&height=400

פרטים:
i = הכתובת של התמונה
width = הרוחב שאתם רוצים לשנות אליו
height = הגובה שאתם רוצים לשנות אליו

היתרונות הם שהסקריפט עובד עם כל סוגי הסיומות. GIF, JPG, PNG, JPEG וכו.....

והנה הוא
הסקריפט:
PHP קוד:
<?php
$file 
$_GET["i"];
$width $_GET["width"];
$height $_GET["height"];
$picname resizepics($file$width$height);
echo 
$pickname;
die( 
"<font color=\"#FF0066\"><center><b>File not exists :(<b></center></FONT>");
function 
resizepics($pics$newwidth$newheight){
     if(
preg_match("/.jpg/i""$pics")){
           
header('Content-type: image/jpeg');
     }
     if (
preg_match("/.gif/i""$pics")){
           
header('Content-type: image/gif');
     } 
     list(
$width$height) = getimagesize($pics);
     if(
$width $height && $newheight $height){
       
$newheight $height / ($width $newwidth);
     } else if (
$width $height && $newwidth $width) {
       
$newwidth $width / ($height $newheight);    
     } else {
       
$newwidth $width;
       
$newheight $height;
   }
   if(
preg_match("/.jpg/i""$pics")){
   
$source imagecreatefromjpeg($pics);
   }
   if(
preg_match("/.jpeg/i""$pics")){
   
$source imagecreatefromjpeg($pics);
   }
   if(
preg_match("/.jpeg/i""$pics")){
   
$source Imagecreatefromjpeg($pics);
   }
   if(
preg_match("/.png/i""$pics")){
   
$source imagecreatefrompng($pics);
   }
   if(
preg_match("/.gif/i""$pics")){
   
$source imagecreatefromgif($pics);
   }
   
$thumb imagecreatetruecolor($newwidth$newheight);
   
imagecopyresized($thumb$source0000$newwidth$newheight$width$height);
   return 
imagejpeg($thumb);
   if(
preg_match("/.jpg/i""$pics")){
   return 
imagejpeg($thumb);
   }
   if(
preg_match("/.jpeg/i""$pics")){
   return 
imagejpeg($thumb);
   }
   if(
preg_match("/.jpeg/i""$pics")){
   return 
imagejpeg($thumb);
   }
   if(
preg_match("/.png/i""$pics")){
   return 
imagepng($thumb);
   }
   if(
preg_match("/.gif/i""$pics")){
   return 
imagegif($thumb);
   }
 }
?>
תהנו ולפחות תפיקו ממנו משהו
__________________
בברכה,
רועי
  Reply With Quote
 

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 14:53.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ