Berkeley CSUA MOTD:Entry 38651
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2024/11/23 [General] UID:1000 Activity:popular
11/23   

2005/7/15-16 [Computer/SW/Languages/Web] UID:38651 Activity:nil
7/14    was ein gutes zu verwendendes Paket (Perl) einfache Linien zu zeichnen
        circles in GIF oder in JPG? Ich möchte etwas tun, das zeichnet
        lines für ein cgi oder ein PHP, Dank.
        \_ ImageMagik?
        \_ GD?
        \_ GD, aber es werden (durch Rückstellung) tun png. (das gerade
           http://us3.php.net/manual/en/ref.image.php -- dbushong
Cache (8192 bytes)
us3.php.net/manual/en/ref.image.php
Image Functions Introduction PHP is not limited to creating just HTML output. It can also be used to c reate and manipulate image files in a variety of different image formats , including gif, png, jpg, wbmp, and xpm. Even more convenient, PHP can output image streams directly to a browser. You will need to compile PHP with the GD library of image functions for this to work. GD and PHP may also require other libraries, depending on which image formats you want to work with. You can use the image functions in PHP to get the size of JPEG, GIF, PNG, SWF, TIFF and JPEG2000 images. Note: Read requirements section about how to expand image capabilities t o read, write and modify images and to read meta data of pictures taken by digital cameras. com/gd/) you will also be able to create and manipulate images. The format of images you are able to manipulate depend on the version of GD you install, and any other libraries GD might need to access those im age formats. This bundl ed version has some additional features like alpha blending, and should be used in preference to the external library since its codebase is be tter maintained and more stable. You may wish to enhance GD to handle more image formats. html It's likely y ou have this library already available, if your system has an installed X-Environment. You may wish to enhance GD to deal with different fonts. edu/pub/Linux/libs/graphics/) Support for Ty pe 1 fonts. If you have PHP compiled with --enable-exif you are able to work with inf ormation stored in headers of JPEG and TIFF images. This way you can rea d meta data generated by digital cameras as mentioned above. To disable GD support in PHP 3 add --without-gd to your configure line. Enhance the capabilities of GD to handle more image formats by specifying the --with-XXXX configure switch to your PHP configure line. Table 3 Supported image formats Image Format Configure Switch jpeg-6b To enable support for jpeg-6b add --with-jpeg-dir=DIR. If configure is not able to find the required libraries, you may add the path to your X11 l ibraries. Note: When compiling PHP with libpng, you must use the same version that was linked with the GD library. Enhance the capabilities of GD to deal with different fonts by specifying the --with-XXXX configure switch to your PHP configure line. Resource Types This extension has no resource types defined. Predefined Constants The constants below are defined by this extension, and will only be avail able when the extension has either been compiled into PHP or dynamically loaded at runtime. header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); Just some header work, the first part makes the image non-cacheable and t he second one ensures the browser gets all the needed information. As I did not need it I did not yet find a way to get the filesize of a GD made image, so I assume you save it to disk, get the filesize and read it again. I hope I just helped you out, and saved you from 2 hours of finding out w hy the stupid PhP has to add data at the beginning of your image. It may look trivial, the Content-Length is not given by default! If, for example, you save a TIFF in Photoshop you are given the option of 'PC' or 'Macintosh': this determines what byte order will be u sed to store the image. If you don't already know about byte order, you probably don't want to! Arguments $values, values should be separed by comma $options may be separed by comma options can be timeline=format, title=a string or image=a source, where format can be sec, min, hour, days/numbe r, days/name, months/number, months/name or years. php function imagegradient($x_size, $y_size, $left_upper="FFFFFF", $right_upper="FF0000", $left_lower="000000", $right_lower="000000") { $image = imagecreatetruecolor($x_size,$y_size); php function Graph($data, $w, $h, $titel, $y_titel, $x_titel, $y_start_with_n ull=true, $x_start_with_null=true) { $typ_farben = array('0000FF', 'FF0000', '006600', 'FF9900', '663300'); i have made little improvements on the last post, so i' ll post the new one here. com> // 2005 - april - 2 // simple script that read "each" pixel from a image and // outputs an html colorized version of it. so, here we determine // how many pixels the script must 'jump' each loop. tip: y jump must be greater // than the x jump, to decrease the distorcion. a value in the array will be one pixel in the asci-ima ge. Thus, writ ing code for my photo album I found that using resize function "imagecop yresampled" would blur my thumbnails. After not finding any way to sharp en my thumbs I wrote this code. Please keep in mind that PHP is not C++ and speed is somewhat slow. The 800x600 image gets sharpened on my machine in 9 seconds. The x value is correct but the y value doesn't consider that a text can have more than one line. The second problem is to find the start position when you want to use ima gettftext(), especially by using an angle > 90. My solution uses some params to generate an image with any text. The imag e size is as small as possible, but you can add a margin without problem s: params: $text > the string you want to write $format > output format "jpeg" or "png" $quality > jpeg quality, from 1 to 100 $font > font path and file $size > font size (px) $angle > angle of text in degrees $r > font color: red part $g > font color: green part $b > font color: blue part $bgr > background color: red part $bgg > bg color: green part $bgb > bg color: blue part $margin > a margin between text and border of pic code: <? Also note that you need to change any occurrence of "imagecreate" to "im agecreatetruecolor" if you will be filling an image that has more than 2 55 rows or columns. Otherwise the function will not be able to create m ore than 255 colours and the results will not look right. I appreciate this is very long-winded (a neater vers ion would probably approach the centre in a sort of spiral movement) but at least it works and, hopefully, is clear. The tolerance is effectively zero, and it takes the top left pixel (0,0) as being the background colour that is to be trimmed. You need to be sure that you have JPG Support on the server before you us e these functions. Use phpinfo() and under the gd-section, see for "JPG Support: Enabled". If you can't see any line like that there, then you'r e missing support. I wrote --with-l ibjpeg-dir, instead of --with-jpeg-dir. It scans 2 images pixel by pixel, from left to right and from top to bott om, if all pixels have equal colors it will return 'True', otherwise it will return 'False'. jpg'> <br> <FORM method='POST' target='_self'> <INPUT TYPE='HIDDEN' name='pasw' value='$enc_text'> <INPUT TYPE='TEXT' name='valr'> <INPUT TYPE='SUBMIT' name='submit'> </FORM> "; php function imagecreatefromfile($filename) { static $image_creators; isset($image_creators)) { $image_creators = array( 1 => "imagecreatefromgif", 2 => "imagecreatefromjpeg", 3 => "imagecreatefrompng", 16 => "imagecreatefromxbm" ); h - no such file or dir ectory" you can check that though by opening the makefile in your fav. editor and ensure lines like: GDLIB_CFLAGS = -I/<phpsourcedir>/ext/gd/libgd -DHAVE_LIBPNG -DHAVE_LIBJPE G read as GDLIB_CFLAGS = -I/<phpsourcedir>/ext/gd/libgd -DHAVE_LIBPNG -DHAVE_LIBJPE G -I/<jpegsourcedir>/jpeg-6b where <jpegsourcedir> and <phpsourcedir> are your equivilent directories. running make will then find the libraries it needs and you should be runn ing. If PHP is already working, you may now activate the GD by doing the follo wing: 1 Uncomment the - extension_dir="". Then you should point it to where th e extensions folder is located. Extensions folder is extracted from PHP zip file you downloaded. In addition to a general overview of the various function catego ries and code samples, I have included many interactive examples of the functions, allowing viewers to experiment with the parameters, and seein g the results in real time. Main "feature" is that the width and height stay relativ to each other. imgcomp is the quality, i turned it around so now its from 0 -best to 100 -most compressed. function resampimagejpg($forcedwidth, $for...