Author Topic: Req: Change Images format at upload.....  (Read 16593 times)

0 Members and 1 Guest are viewing this topic.

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Req: Change Images format at upload.....
« on: February 17, 2006, 03:55:49 AM »
I've just GD librabry so this only work with jpg, so its possible convert all images uploaded to jpg format ? make gif,png,etc all to jpg ?

 :?:

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Req: Change Images format at upload.....
« Reply #1 on: February 17, 2006, 03:58:27 AM »
I'm not sure what you mean Stoleti. GD Library is using GIF and PNG formats since v2.0.32. The manufacturer is now up to v2.0.33. ;)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: Req: Change Images format at upload.....
« Reply #2 on: February 17, 2006, 04:00:35 AM »
I'm not sure what you mean Stoleti. GD Library is using GIF and PNG formats since v2.0.32. The manufacturer is now up to v2.0.33. ;)


Well the watermark its just working with jpg images .....


GIF,PNG.....doesn't work...  :?

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Req: Change Images format at upload.....
« Reply #3 on: February 17, 2006, 04:02:31 AM »
Which version of GD do you have ?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Req: Change Images format at upload.....
« Reply #4 on: February 17, 2006, 04:57:57 AM »
in includes/image_utils.php find:
Code: [Select]
    $image_handle = "image".$types[$image_info[2]];replace with:
Code: [Select]
    $image_handle = "imagejpeg";
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Req: Change Images format at upload.....
« Reply #5 on: February 17, 2006, 01:56:39 PM »
Is it also possible to add these types in an array in case of additional extensions that would be involved ?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Req: Change Images format at upload.....
« Reply #6 on: February 17, 2006, 03:15:37 PM »
what?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Req: Change Images format at upload.....
« Reply #7 on: February 17, 2006, 03:22:45 PM »
Yes, of course - an example :

Quote

$image_handle = "imagejpeg";


Would there be a way to do it like this :

Quote

$image_array = array("imagejpeg", "imagegif", "imagepng");

if (in_array("imagejpeg")) {
$image_handle = "imagejpeg";
} elseif (in_array("imagegif")) {
$image_handle = "imagegif";
} elseif (in_array("imagepng")) {
$image_handle = "imagepng";
} ###### End of if statement.


?

This would be useful since GD also involves GIF and PNG now.

Recall: The above is just an example. The rest of the $image_handle's equalitys might not even exist as a name. ;)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: Req: Change Images format at upload.....
« Reply #8 on: February 17, 2006, 03:34:03 PM »
in includes/image_utils.php find:
Code: [Select]
    $image_handle = "image".$types[$image_info[2]];replace with:
Code: [Select]
    $image_handle = "imagejpeg";

This doesn't work ... images still with same format (original) and not change to jpg/jpeg...when upload


My GD 2.0.28   :|

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Req: Change Images format at upload.....
« Reply #9 on: February 17, 2006, 03:45:54 PM »
@V@no:

Sorry, I meant something like this (more appropriate) :

Quote

if (preg_match("#(jpg|jpeg)$#is", $image_handle))) {
$image_handle = "imagejpeg";
} elseif (preg_match("#(gif)$#is", $image_handle))) {
$image_handle = "imagegif";
} elseif (preg_match("#(png)$#is", $image_handle))) {
$image_handle = "imagepng";
} ###### End of if statement.


Could something relative be done ?

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: Req: Change Images format at upload.....
« Reply #10 on: February 17, 2006, 07:03:21 PM »
@V@no:

Sorry, I meant something like this (more appropriate) :

Quote

if (preg_match("#(jpg|jpeg)$#is", $image_handle))) {
$image_handle = "imagejpeg";
} elseif (preg_match("#(gif)$#is", $image_handle))) {
$image_handle = "imagegif";
} elseif (preg_match("#(png)$#is", $image_handle))) {
$image_handle = "imagepng";
} ###### End of if statement.


Could something relative be done ?

Replacing $image_handle = "image".$types[$image_info[2]]; with that ?  :|

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Req: Change Images format at upload.....
« Reply #11 on: February 18, 2006, 12:34:27 AM »
@Stoleti:
possibilities:
1) you did not change the file on the server
2) you made a misstake
3) you are not using GD as graphic module in 4images

@TheOracle:
1) the extension can be deceptive
2) your example is equal to this:
Code: [Select]
    $types = array(1 => "gif", 2 => "jpeg", 3 => "png");
    $image_handle = "image".$types[$image_info[2]];
which is already present in 4images, except its slower.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Req: Change Images format at upload.....
« Reply #12 on: February 18, 2006, 12:38:42 AM »
Does this bolded part :

Quote

$types[$image_info[2]]


means JPG in this case ? (2nd number in the array)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Req: Change Images format at upload.....
« Reply #13 on: February 18, 2006, 12:42:48 AM »
means JPG in this case ? (2nd number in the array)
No, it conteins type of the image. More info here
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: Req: Change Images format at upload.....
« Reply #14 on: February 18, 2006, 01:08:47 AM »
@Stoleti:
possibilities:
1) you did not change the file on the server
2) you made a misstake
3) you are not using GD as graphic module in 4images

@TheOracle:
1) the extension can be deceptive
2) your example is equal to this:
Code: [Select]
    $types = array(1 => "gif", 2 => "jpeg", 3 => "png");
    $image_handle = "image".$types[$image_info[2]];
which is already present in 4images, except its slower.


I've make your modification,without mistakes , and yes i'm using GD in 4 images ;)