Portrety Uliczne Nieznajomych - zobacz wyjątkową galerię portretów z warszawskich ulic
ZALOGUJ SIĘ
login:
hasło:
przypomnij hasło
załóż konto użytkownika
(i zobacz kilka porad gratis)
   
WYSZUKIWARKA I DZIAŁY
całe porady  tytuły
zaznacz działy do przeszukania
(brak wyboru = wszystkie działy)
PHP
MySQL >
PostgreSQL
SQLite
Perl
Java
XML
XSLT
XPath
WML
SVG
RegExp
Wyszukiwarki
Ochrona
VBScript
Google Plus
XHTML/CSS
JavaScript
Grafika
Flash
Photoshop
Windows
Linux
Bash
Apache
Procmail
E-biznes
Explorer
Opera
Firefox
Inne porady
   
KURSY, DOKUMENTACJE
Własne:
XHTML/CSS
JavaScript
ActionScript
WML, RSS, SSI
Pozostałe:
PHP
MySQL
Java API
więcej...
   
użytkowników online: 17
W CZYM MOGĘ POMÓC?


   
OPINIE UŻYTKOWNIKÓW
Po wysłaniu do Dariusza problemu jeszcze nie opisanego w poradach, odpowiedź pojawia się na stronach już po 24 godzinach. To jedna z najważniejszych zalet serwisu! Za około 100 złotych rocznie mam profesjonalnego i doświadczonego konsultanta od technologii internetowych! Polecam serwis z poradami każdemu webmasterowi, niezależnie od stażu pracy i umiejętności.

Paweł Kowalski
grupa hiperMEDIA.pl

   
GALERIA FOTOGRAFII
   
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net

[Spis] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [X] [W] [Z]

imagetypes

(PHP 3 CVS only, PHP 4 >= 4.0.2, PHP 5)

imagetypes -- Return the image types supported by this PHP build

Description

int imagetypes ( void )

This function returns a bit-field corresponding to the image formats supported by the version of GD linked into PHP. The following bits are returned, IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM. To check for PNG support, for example, do this:

Przykład 1. imagetypes() example

<?php
if (imagetypes() & IMG_PNG) {
   echo
"PNG Support is enabled";
}
?>




User Contributed Notes

enyo
06-Nov-2003 04:32

Why not use this function?

<?php
function getSupportedImageTypes() {
  
$aSupportedTypes = array();

  
$aPossibleImageTypeBits = array(
      
IMG_GIF=>'GIF',
      
IMG_JPG=>'JPG',
      
IMG_PNG=>'PNG',
      
IMG_WBMP=>'WBMP'
  
);

   foreach (
$aPossibleImageTypeBits as $iImageTypeBits => $sImageTypeString) {
       if (
imagetypes() & $iImageTypeBits) {
          
$aSupportedTypes[] = $sImageTypeString;
       }
   }

   return
$aSupportedTypes;
}
?>


jocke at selincite dot IHATESP4M dot com
16-Oct-2003 11:56

I wrote this function that returns an array with the supported image types

<?php
function getSupportedImageTypes() {
      
$aSupportedTypes = array();
      
      
$aPossibleImageTypeBits = array(
              
"IMG_GIF",
              
"IMG_JPG",
              
"IMG_PNG",
              
"IMG_WBMP"
          
);
          
       foreach (
$aPossibleImageTypeBits as $iIndex => $sImageTypeBits) {
          
          
$sEval  = "if (";
          
$sEval .= "imagetypes() & " . $sImageTypeBits . "";
          
$sEval .= ") { return TRUE; } else { return FALSE; }";
          
           if (eval(
$sEval)) {
              
$aSupportedTypes[] = str_replace("IMG_", "", $sImageTypeBits);
           }
       }
      
       return
$aSupportedTypes;
   }
?>
Hope that helps someone :)

/Jocke Selin

PS, if you know of a better way that doesn't include eval(), please let me know.


jaldinger (at) consulturdorado (dot) com
08-Jan-2003 09:31

Please note that if only "GIF Read Support" is enabled, the
IMG_GIF bit will not be returned (at least on my system:
PHP 4.3.0/RH Linux 7.2).

To work around this issue, and also the issue that there is no
function that can tell me what image format a GD resource ID
refers to, I use the following switch statement to map the exif
IMAGETYPE_* constants to the GD IMG_* constants:

switch (exif_imagetype($file['tmp_name'])) {
   case IMAGETYPE_GIF:
       $image_type = IMG_GIF;
       break;
   case IMAGETYPE_JPEG:
       $image_type = IMG_JPG;
       break;
   case IMAGETYPE_PNG:
       $image_type = IMG_PNG;
       break;
   case IMAGETYPE_WBMP:
       $image_type = IMG_WBMP;
       break;
     default:
       $image_type = 0;
       break;
}

store this value together with the image data in a database
and later use the following IF statement to see if I can work
with that image (create a thumbnail, etc...)

if ($image_type & (imagetypes() | IMG_GIF)) {
   return $this->createJpegThumbailFromString($data, 46, 27);
} else {
   return file_get_contents($_SERVER['DOCUMENT_ROOT'] .
       '/gfx/no-thumbnail.jpg');
}

HTH anybody...

Joerg.


 

 
  © 1996-2012 & Reporter.plmiejscao serwisieabonamentwarunki korzystaniaRSSkontakt