├── README.md ├── changelog ├── class-php-ico.php ├── composer.json └── license.txt /README.md: -------------------------------------------------------------------------------- 1 | PHP ICO - The PHP ICO Generator 2 | =============================== 3 | 4 | PHP ICO provides an easy-to-use PHP class that generates valid [ICO files](http://en.wikipedia.org/wiki/ICO_%28file_format%29). Note that these are not simply BMP, GIF, or PNG formatted images with an extension of ico, the images generated by this class are fully valid ICO-formatted image files. 5 | 6 | The class uses the GD library for reading an image from the source file and uses pure PHP for generating the ICO file format. In theory, any image format that GD can read can be used as a source image to generate the ICO file. I tested this library with JPEG, GIF, and PNG images with great results. If an animated GIF is supplied, the first frame will be used to generate the ICO image. 7 | 8 | The PHP ICO library is available on Composer via Packagist at `chrisjean/php-ico`. 9 | 10 | ICO Format Details 11 | ------------------ 12 | 13 | The primary goal of creating this class was to have a simple-to-use and reliable method of generating ICO files for use as [favicons](http://en.wikipedia.org/wiki/Favicon) in websites. This goal drove much of the development and is the reason for some of the limitations in the resulting functionality. 14 | 15 | ICO files support two different ways of encoding the actual image data: the [Windows BMP](http://en.wikipedia.org/wiki/BMP_file_format) format and the [PNG](http://en.wikipedia.org/wiki/Portable_Network_Graphics) format. Since support for the PNG format was introduced in Windows Vista and both older and newer versions of Windows support the BMP enocoding, the BMP encoding method was used. 16 | 17 | Images are encoded using 32 bits per pixel. This allows for alpha channel information in the resulting images. Support for 32 bit images was added in Windows XP. This means that older versions of Windows are not likely to display the ICO images properly, if at all. The generated images have not been tested on versions of Windows predating XP. 18 | 19 | Usage 20 | ----- 21 | 22 | The following is a very basic example of using the PHP ICO library: 23 | 24 | ```php 25 | require( dirname( __FILE__ ) . '/class-php-ico.php' ); 26 | 27 | $source = dirname( __FILE__ ) . '/example.gif'; 28 | $destination = dirname( __FILE__ ) . '/example.ico'; 29 | 30 | $ico_lib = new PHP_ICO( $source ); 31 | $ico_lib->save_ico( $destination ); 32 | ```` 33 | 34 | It takes a source file named `example.gif` and produce an output ICO file named `example.ico`. `example.ico` will contain a single image that is the same size as the source image. 35 | 36 | The ICO file format is capable of holding multiple images, each of a different size. The PHP ICO library opens up this feature of the ICO format as shown in the following example: 37 | 38 | ```php 39 | require( dirname( __FILE__ ) . '/class-php-ico.php' ); 40 | 41 | $source = dirname( __FILE__ ) . '/example.gif'; 42 | $destination = dirname( __FILE__ ) . '/example.ico'; 43 | 44 | $ico_lib = new PHP_ICO( $source, array( array( 32, 32 ), array( 64, 64 ) ) ); 45 | $ico_lib->save_ico( $destination ); 46 | ``` 47 | 48 | As with the previous example, this example produces `example.ico` from the `example.gif` source file. In this example, sizes were passed to the constructor that result in the `example.ico` file containing two images: one that is 32x32 and one that is 64x64. Since the same source image is used for each of the contained images, each contained image is simply the source image scaled to the new dimensions. 49 | 50 | Using different source images for the different sizes contained inside an ICO file can create much better results. For instance, you can use a high-quality image for higher-resolution images and use smaller images that are tailored for their specific dimensions for the smaller sizes. The following example shows how the PHP ICO library can be used to create such ICO files: 51 | 52 | ```php 53 | require( dirname( __FILE__ ) . '/class-php-ico.php' ); 54 | 55 | $destination = dirname( __FILE__ ) . '/example.ico'; 56 | 57 | $ico_lib = new PHP_ICO(); 58 | 59 | $ico_lib->add_image( dirname( __FILE__ ) . '/example-small.gif', array( array( 16, 16 ), array( 24, 24 ), array( 32, 32 ) ) ); 60 | $ico_lib->add_image( dirname( __FILE__ ) . '/example-medium.gif', array( array( 48, 48 ), array( 96, 96 ) ) ); 61 | $ico_lib->add_image( dirname( __FILE__ ) . '/example-large.gif', array( array( 128, 128 ) ) ); 62 | 63 | $ico_lib->save_ico( $destination ); 64 | ``` 65 | 66 | This example creates a single ICO file named `example.ico` just as the previous examples. The difference is that this example used multiple source images to generate the final ICO images. The final ICO image contains a total of six images: 16x16, 24x24, and 32x32 images from `example-small.gif`; 48x48 and 96x96 images from `example-medium.gif`; and a 128x128 image from `example-large.gif`. 67 | 68 | By using this feature of supplying multiple source images with specific sizes for each, you can generate ICO files that have very high-quality images at each supplied resolution. 69 | 70 | Since the PHP ICO library was created to generate favicon files, the following example shows how to generate a favicon ICO file with all the needed dimensions from a single source image: 71 | 72 | ```php 73 | require( dirname( __FILE__ ) . '/class-php-ico.php' ); 74 | 75 | $source = dirname( __FILE__ ) . '/example.gif'; 76 | $destination = dirname( __FILE__ ) . '/example.ico'; 77 | 78 | $sizes = array( 79 | array( 16, 16 ), 80 | array( 24, 24 ), 81 | array( 32, 32 ), 82 | array( 48, 48 ), 83 | ); 84 | 85 | $ico_lib = new PHP_ICO( $source, $sizes ); 86 | $ico_lib->save_ico( $destination ); 87 | ``` 88 | 89 | I've found that the 16x16, 24x24, 32x32, and 48x48 image sizes cover all the sizes that browsers and Windows will try to use a favicon image for. The different sizes come from using the favicon for various browser icons, bookmarks, and various other places. 90 | 91 | Thanks 92 | ------ 93 | 94 | I'd like to thank [iThemes](http://ithemes.com) for making this project possible. This code was originally developed to add easy-to-use favicon support to the [Builder theme](http://ithemes.com/purchase/builder-theme/). I asked [Cory](http://corymiller.tv/), owner of iThemes and my boss, if I could share the final code. He gave me the green light. Win for everyone. :) 95 | 96 | Thanks iThemes. Thanks Cory. 97 | -------------------------------------------------------------------------------- /changelog: -------------------------------------------------------------------------------- 1 | 1.0.0 - 2011-08-04 2 | Initial version. 3 | 1.0.1 - 2012-10-01 4 | Added requirements checks. 5 | 1.0.2 - 2013-01-07 6 | Added bug fix that caused source images with transparency to have artifacts when output at the same dimensions as the source. 7 | 1.0.3 - 2016-07-22 8 | Updated class constructor to __construct() as PHP4-style constructors are now deprecated. Props @nuxodin. 9 | Removed trailing whitespace from blank lines. 10 | 1.0.4 - 2016-09-27 11 | Updated version to get composer to track properly. 12 | -------------------------------------------------------------------------------- /class-php-ico.php: -------------------------------------------------------------------------------- 1 | _has_requirements = true; 59 | 60 | 61 | if ( false != $file ) 62 | $this->add_image( $file, $sizes ); 63 | } 64 | 65 | /** 66 | * Add an image to the generator. 67 | * 68 | * This function adds a source image to the generator. It serves two main purposes: add a source image if one was 69 | * not supplied to the constructor and to add additional source images so that different images can be supplied for 70 | * different sized images in the resulting ICO file. For instance, a small source image can be used for the small 71 | * resolutions while a larger source image can be used for large resolutions. 72 | * 73 | * @param string $file Path to the source image file. 74 | * @param array $sizes Optional. An array of sizes (each size is an array with a width and height) that the source image should be rendered at in the generated ICO file. If sizes are not supplied, the size of the source image will be used. 75 | * @return boolean true on success and false on failure. 76 | */ 77 | function add_image( $file, $sizes = array() ) { 78 | if ( ! $this->_has_requirements ) 79 | return false; 80 | 81 | if ( false === ( $im = $this->_load_image_file( $file ) ) ) 82 | return false; 83 | 84 | 85 | if ( empty( $sizes ) ) 86 | $sizes = array( imagesx( $im ), imagesy( $im ) ); 87 | 88 | // If just a single size was passed, put it in array. 89 | if ( ! is_array( $sizes[0] ) ) 90 | $sizes = array( $sizes ); 91 | 92 | foreach ( (array) $sizes as $size ) { 93 | list( $width, $height ) = $size; 94 | 95 | $new_im = imagecreatetruecolor( $width, $height ); 96 | 97 | imagecolortransparent( $new_im, imagecolorallocatealpha( $new_im, 0, 0, 0, 127 ) ); 98 | imagealphablending( $new_im, false ); 99 | imagesavealpha( $new_im, true ); 100 | 101 | $source_width = imagesx( $im ); 102 | $source_height = imagesy( $im ); 103 | 104 | if ( false === imagecopyresampled( $new_im, $im, 0, 0, 0, 0, $width, $height, $source_width, $source_height ) ) 105 | continue; 106 | 107 | $this->_add_image_data( $new_im ); 108 | } 109 | 110 | return true; 111 | } 112 | 113 | /** 114 | * Write the ICO file data to a file path. 115 | * 116 | * @param string $file Path to save the ICO file data into. 117 | * @return boolean true on success and false on failure. 118 | */ 119 | function save_ico( $file ) { 120 | if ( ! $this->_has_requirements ) 121 | return false; 122 | 123 | if ( false === ( $data = $this->_get_ico_data() ) ) 124 | return false; 125 | 126 | if ( false === ( $fh = fopen( $file, 'w' ) ) ) 127 | return false; 128 | 129 | if ( false === ( fwrite( $fh, $data ) ) ) { 130 | fclose( $fh ); 131 | return false; 132 | } 133 | 134 | fclose( $fh ); 135 | 136 | return true; 137 | } 138 | 139 | /** 140 | * Generate the final ICO data by creating a file header and adding the image data. 141 | * 142 | * @access private 143 | */ 144 | function _get_ico_data() { 145 | if ( ! is_array( $this->_images ) || empty( $this->_images ) ) 146 | return false; 147 | 148 | 149 | $data = pack( 'vvv', 0, 1, count( $this->_images ) ); 150 | $pixel_data = ''; 151 | 152 | $icon_dir_entry_size = 16; 153 | 154 | $offset = 6 + ( $icon_dir_entry_size * count( $this->_images ) ); 155 | 156 | foreach ( $this->_images as $image ) { 157 | $data .= pack( 'CCCCvvVV', $image['width'], $image['height'], $image['color_palette_colors'], 0, 1, $image['bits_per_pixel'], $image['size'], $offset ); 158 | $pixel_data .= $image['data']; 159 | 160 | $offset += $image['size']; 161 | } 162 | 163 | $data .= $pixel_data; 164 | unset( $pixel_data ); 165 | 166 | 167 | return $data; 168 | } 169 | 170 | /** 171 | * Take a GD image resource and change it into a raw BMP format. 172 | * 173 | * @access private 174 | */ 175 | function _add_image_data( $im ) { 176 | $width = imagesx( $im ); 177 | $height = imagesy( $im ); 178 | 179 | 180 | $pixel_data = array(); 181 | 182 | $opacity_data = array(); 183 | $current_opacity_val = 0; 184 | 185 | for ( $y = $height - 1; $y >= 0; $y-- ) { 186 | for ( $x = 0; $x < $width; $x++ ) { 187 | $color = imagecolorat( $im, $x, $y ); 188 | 189 | $alpha = ( $color & 0x7F000000 ) >> 24; 190 | $alpha = ( 1 - ( $alpha / 127 ) ) * 255; 191 | 192 | $color &= 0xFFFFFF; 193 | $color |= 0xFF000000 & ( $alpha << 24 ); 194 | 195 | $pixel_data[] = $color; 196 | 197 | 198 | $opacity = ( $alpha <= 127 ) ? 1 : 0; 199 | 200 | $current_opacity_val = ( $current_opacity_val << 1 ) | $opacity; 201 | 202 | if ( ( ( $x + 1 ) % 32 ) == 0 ) { 203 | $opacity_data[] = $current_opacity_val; 204 | $current_opacity_val = 0; 205 | } 206 | } 207 | 208 | if ( ( $x % 32 ) > 0 ) { 209 | while ( ( $x++ % 32 ) > 0 ) 210 | $current_opacity_val = $current_opacity_val << 1; 211 | 212 | $opacity_data[] = $current_opacity_val; 213 | $current_opacity_val = 0; 214 | } 215 | } 216 | 217 | $image_header_size = 40; 218 | $color_mask_size = $width * $height * 4; 219 | $opacity_mask_size = ( ceil( $width / 32 ) * 4 ) * $height; 220 | 221 | 222 | $data = pack( 'VVVvvVVVVVV', 40, $width, ( $height * 2 ), 1, 32, 0, 0, 0, 0, 0, 0 ); 223 | 224 | foreach ( $pixel_data as $color ) 225 | $data .= pack( 'V', $color ); 226 | 227 | foreach ( $opacity_data as $opacity ) 228 | $data .= pack( 'N', $opacity ); 229 | 230 | 231 | $image = array( 232 | 'width' => $width, 233 | 'height' => $height, 234 | 'color_palette_colors' => 0, 235 | 'bits_per_pixel' => 32, 236 | 'size' => $image_header_size + $color_mask_size + $opacity_mask_size, 237 | 'data' => $data, 238 | ); 239 | 240 | $this->_images[] = $image; 241 | } 242 | 243 | /** 244 | * Read in the source image file and convert it into a GD image resource. 245 | * 246 | * @access private 247 | */ 248 | function _load_image_file( $file ) { 249 | // Run a cheap check to verify that it is an image file. 250 | if ( false === ( $size = getimagesize( $file ) ) ) 251 | return false; 252 | 253 | if ( false === ( $file_data = file_get_contents( $file ) ) ) 254 | return false; 255 | 256 | if ( false === ( $im = imagecreatefromstring( $file_data ) ) ) 257 | return false; 258 | 259 | unset( $file_data ); 260 | 261 | 262 | return $im; 263 | } 264 | } 265 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chrisjean/php-ico", 3 | "description": "An easy-to-use library to generate valid ICO files.", 4 | "version": "1.0.4", 5 | "keywords": ["ico", "favicon"], 6 | "homepage": "https://github.com/chrisbliss18/php-ico", 7 | "license": "GPL-2.0+", 8 | "authors": [ 9 | { 10 | "name": "Chris Jean", 11 | "homepage": "https://chrisjean.com", 12 | "role": "Developer" 13 | } 14 | ], 15 | "support": { 16 | "issues": "https://github.com/chrisbliss18/php-ico/issues", 17 | "source": "https://github.com/chrisbliss18/php-ico" 18 | }, 19 | "require": { 20 | "php": ">=5.2.4", 21 | "ext-gd": "*" 22 | }, 23 | "autoload": { 24 | "classmap": [ 25 | "class-php-ico.php" 26 | ] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | PHP ICO - The PHP ICO Generator 2 | 3 | Copyright 2011-2016 Chris Jean 4 | 5 | PHP ICO is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | PHP ICO is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with PHP ICO; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 20 | 21 | GNU GENERAL PUBLIC LICENSE 22 | Version 2, June 1991 23 | 24 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 25 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 26 | Everyone is permitted to copy and distribute verbatim copies 27 | of this license document, but changing it is not allowed. 28 | 29 | Preamble 30 | 31 | The licenses for most software are designed to take away your 32 | freedom to share and change it. By contrast, the GNU General Public 33 | License is intended to guarantee your freedom to share and change free 34 | software--to make sure the software is free for all its users. This 35 | General Public License applies to most of the Free Software 36 | Foundation's software and to any other program whose authors commit to 37 | using it. (Some other Free Software Foundation software is covered by 38 | the GNU Lesser General Public License instead.) You can apply it to 39 | your programs, too. 40 | 41 | When we speak of free software, we are referring to freedom, not 42 | price. Our General Public Licenses are designed to make sure that you 43 | have the freedom to distribute copies of free software (and charge for 44 | this service if you wish), that you receive source code or can get it 45 | if you want it, that you can change the software or use pieces of it 46 | in new free programs; and that you know you can do these things. 47 | 48 | To protect your rights, we need to make restrictions that forbid 49 | anyone to deny you these rights or to ask you to surrender the rights. 50 | These restrictions translate to certain responsibilities for you if you 51 | distribute copies of the software, or if you modify it. 52 | 53 | For example, if you distribute copies of such a program, whether 54 | gratis or for a fee, you must give the recipients all the rights that 55 | you have. You must make sure that they, too, receive or can get the 56 | source code. And you must show them these terms so they know their 57 | rights. 58 | 59 | We protect your rights with two steps: (1) copyright the software, and 60 | (2) offer you this license which gives you legal permission to copy, 61 | distribute and/or modify the software. 62 | 63 | Also, for each author's protection and ours, we want to make certain 64 | that everyone understands that there is no warranty for this free 65 | software. If the software is modified by someone else and passed on, we 66 | want its recipients to know that what they have is not the original, so 67 | that any problems introduced by others will not reflect on the original 68 | authors' reputations. 69 | 70 | Finally, any free program is threatened constantly by software 71 | patents. We wish to avoid the danger that redistributors of a free 72 | program will individually obtain patent licenses, in effect making the 73 | program proprietary. To prevent this, we have made it clear that any 74 | patent must be licensed for everyone's free use or not licensed at all. 75 | 76 | The precise terms and conditions for copying, distribution and 77 | modification follow. 78 | 79 | GNU GENERAL PUBLIC LICENSE 80 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 81 | 82 | 0. This License applies to any program or other work which contains 83 | a notice placed by the copyright holder saying it may be distributed 84 | under the terms of this General Public License. The "Program", below, 85 | refers to any such program or work, and a "work based on the Program" 86 | means either the Program or any derivative work under copyright law: 87 | that is to say, a work containing the Program or a portion of it, 88 | either verbatim or with modifications and/or translated into another 89 | language. (Hereinafter, translation is included without limitation in 90 | the term "modification".) Each licensee is addressed as "you". 91 | 92 | Activities other than copying, distribution and modification are not 93 | covered by this License; they are outside its scope. The act of 94 | running the Program is not restricted, and the output from the Program 95 | is covered only if its contents constitute a work based on the 96 | Program (independent of having been made by running the Program). 97 | Whether that is true depends on what the Program does. 98 | 99 | 1. You may copy and distribute verbatim copies of the Program's 100 | source code as you receive it, in any medium, provided that you 101 | conspicuously and appropriately publish on each copy an appropriate 102 | copyright notice and disclaimer of warranty; keep intact all the 103 | notices that refer to this License and to the absence of any warranty; 104 | and give any other recipients of the Program a copy of this License 105 | along with the Program. 106 | 107 | You may charge a fee for the physical act of transferring a copy, and 108 | you may at your option offer warranty protection in exchange for a fee. 109 | 110 | 2. You may modify your copy or copies of the Program or any portion 111 | of it, thus forming a work based on the Program, and copy and 112 | distribute such modifications or work under the terms of Section 1 113 | above, provided that you also meet all of these conditions: 114 | 115 | a) You must cause the modified files to carry prominent notices 116 | stating that you changed the files and the date of any change. 117 | 118 | b) You must cause any work that you distribute or publish, that in 119 | whole or in part contains or is derived from the Program or any 120 | part thereof, to be licensed as a whole at no charge to all third 121 | parties under the terms of this License. 122 | 123 | c) If the modified program normally reads commands interactively 124 | when run, you must cause it, when started running for such 125 | interactive use in the most ordinary way, to print or display an 126 | announcement including an appropriate copyright notice and a 127 | notice that there is no warranty (or else, saying that you provide 128 | a warranty) and that users may redistribute the program under 129 | these conditions, and telling the user how to view a copy of this 130 | License. (Exception: if the Program itself is interactive but 131 | does not normally print such an announcement, your work based on 132 | the Program is not required to print an announcement.) 133 | 134 | These requirements apply to the modified work as a whole. If 135 | identifiable sections of that work are not derived from the Program, 136 | and can be reasonably considered independent and separate works in 137 | themselves, then this License, and its terms, do not apply to those 138 | sections when you distribute them as separate works. But when you 139 | distribute the same sections as part of a whole which is a work based 140 | on the Program, the distribution of the whole must be on the terms of 141 | this License, whose permissions for other licensees extend to the 142 | entire whole, and thus to each and every part regardless of who wrote it. 143 | 144 | Thus, it is not the intent of this section to claim rights or contest 145 | your rights to work written entirely by you; rather, the intent is to 146 | exercise the right to control the distribution of derivative or 147 | collective works based on the Program. 148 | 149 | In addition, mere aggregation of another work not based on the Program 150 | with the Program (or with a work based on the Program) on a volume of 151 | a storage or distribution medium does not bring the other work under 152 | the scope of this License. 153 | 154 | 3. You may copy and distribute the Program (or a work based on it, 155 | under Section 2) in object code or executable form under the terms of 156 | Sections 1 and 2 above provided that you also do one of the following: 157 | 158 | a) Accompany it with the complete corresponding machine-readable 159 | source code, which must be distributed under the terms of Sections 160 | 1 and 2 above on a medium customarily used for software interchange; or, 161 | 162 | b) Accompany it with a written offer, valid for at least three 163 | years, to give any third party, for a charge no more than your 164 | cost of physically performing source distribution, a complete 165 | machine-readable copy of the corresponding source code, to be 166 | distributed under the terms of Sections 1 and 2 above on a medium 167 | customarily used for software interchange; or, 168 | 169 | c) Accompany it with the information you received as to the offer 170 | to distribute corresponding source code. (This alternative is 171 | allowed only for noncommercial distribution and only if you 172 | received the program in object code or executable form with such 173 | an offer, in accord with Subsection b above.) 174 | 175 | The source code for a work means the preferred form of the work for 176 | making modifications to it. For an executable work, complete source 177 | code means all the source code for all modules it contains, plus any 178 | associated interface definition files, plus the scripts used to 179 | control compilation and installation of the executable. However, as a 180 | special exception, the source code distributed need not include 181 | anything that is normally distributed (in either source or binary 182 | form) with the major components (compiler, kernel, and so on) of the 183 | operating system on which the executable runs, unless that component 184 | itself accompanies the executable. 185 | 186 | If distribution of executable or object code is made by offering 187 | access to copy from a designated place, then offering equivalent 188 | access to copy the source code from the same place counts as 189 | distribution of the source code, even though third parties are not 190 | compelled to copy the source along with the object code. 191 | 192 | 4. You may not copy, modify, sublicense, or distribute the Program 193 | except as expressly provided under this License. Any attempt 194 | otherwise to copy, modify, sublicense or distribute the Program is 195 | void, and will automatically terminate your rights under this License. 196 | However, parties who have received copies, or rights, from you under 197 | this License will not have their licenses terminated so long as such 198 | parties remain in full compliance. 199 | 200 | 5. You are not required to accept this License, since you have not 201 | signed it. However, nothing else grants you permission to modify or 202 | distribute the Program or its derivative works. These actions are 203 | prohibited by law if you do not accept this License. Therefore, by 204 | modifying or distributing the Program (or any work based on the 205 | Program), you indicate your acceptance of this License to do so, and 206 | all its terms and conditions for copying, distributing or modifying 207 | the Program or works based on it. 208 | 209 | 6. Each time you redistribute the Program (or any work based on the 210 | Program), the recipient automatically receives a license from the 211 | original licensor to copy, distribute or modify the Program subject to 212 | these terms and conditions. You may not impose any further 213 | restrictions on the recipients' exercise of the rights granted herein. 214 | You are not responsible for enforcing compliance by third parties to 215 | this License. 216 | 217 | 7. If, as a consequence of a court judgment or allegation of patent 218 | infringement or for any other reason (not limited to patent issues), 219 | conditions are imposed on you (whether by court order, agreement or 220 | otherwise) that contradict the conditions of this License, they do not 221 | excuse you from the conditions of this License. If you cannot 222 | distribute so as to satisfy simultaneously your obligations under this 223 | License and any other pertinent obligations, then as a consequence you 224 | may not distribute the Program at all. For example, if a patent 225 | license would not permit royalty-free redistribution of the Program by 226 | all those who receive copies directly or indirectly through you, then 227 | the only way you could satisfy both it and this License would be to 228 | refrain entirely from distribution of the Program. 229 | 230 | If any portion of this section is held invalid or unenforceable under 231 | any particular circumstance, the balance of the section is intended to 232 | apply and the section as a whole is intended to apply in other 233 | circumstances. 234 | 235 | It is not the purpose of this section to induce you to infringe any 236 | patents or other property right claims or to contest validity of any 237 | such claims; this section has the sole purpose of protecting the 238 | integrity of the free software distribution system, which is 239 | implemented by public license practices. Many people have made 240 | generous contributions to the wide range of software distributed 241 | through that system in reliance on consistent application of that 242 | system; it is up to the author/donor to decide if he or she is willing 243 | to distribute software through any other system and a licensee cannot 244 | impose that choice. 245 | 246 | This section is intended to make thoroughly clear what is believed to 247 | be a consequence of the rest of this License. 248 | 249 | 8. If the distribution and/or use of the Program is restricted in 250 | certain countries either by patents or by copyrighted interfaces, the 251 | original copyright holder who places the Program under this License 252 | may add an explicit geographical distribution limitation excluding 253 | those countries, so that distribution is permitted only in or among 254 | countries not thus excluded. In such case, this License incorporates 255 | the limitation as if written in the body of this License. 256 | 257 | 9. The Free Software Foundation may publish revised and/or new versions 258 | of the General Public License from time to time. Such new versions will 259 | be similar in spirit to the present version, but may differ in detail to 260 | address new problems or concerns. 261 | 262 | Each version is given a distinguishing version number. If the Program 263 | specifies a version number of this License which applies to it and "any 264 | later version", you have the option of following the terms and conditions 265 | either of that version or of any later version published by the Free 266 | Software Foundation. If the Program does not specify a version number of 267 | this License, you may choose any version ever published by the Free Software 268 | Foundation. 269 | 270 | 10. If you wish to incorporate parts of the Program into other free 271 | programs whose distribution conditions are different, write to the author 272 | to ask for permission. For software which is copyrighted by the Free 273 | Software Foundation, write to the Free Software Foundation; we sometimes 274 | make exceptions for this. Our decision will be guided by the two goals 275 | of preserving the free status of all derivatives of our free software and 276 | of promoting the sharing and reuse of software generally. 277 | 278 | NO WARRANTY 279 | 280 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 281 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 282 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 283 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 284 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 285 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 286 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 287 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 288 | REPAIR OR CORRECTION. 289 | 290 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 291 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 292 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 293 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 294 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 295 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 296 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 297 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 298 | POSSIBILITY OF SUCH DAMAGES. 299 | 300 | END OF TERMS AND CONDITIONS 301 | 302 | How to Apply These Terms to Your New Programs 303 | 304 | If you develop a new program, and you want it to be of the greatest 305 | possible use to the public, the best way to achieve this is to make it 306 | free software which everyone can redistribute and change under these terms. 307 | 308 | To do so, attach the following notices to the program. It is safest 309 | to attach them to the start of each source file to most effectively 310 | convey the exclusion of warranty; and each file should have at least 311 | the "copyright" line and a pointer to where the full notice is found. 312 | 313 | 314 | Copyright (C) 315 | 316 | This program is free software; you can redistribute it and/or modify 317 | it under the terms of the GNU General Public License as published by 318 | the Free Software Foundation; either version 2 of the License, or 319 | (at your option) any later version. 320 | 321 | This program is distributed in the hope that it will be useful, 322 | but WITHOUT ANY WARRANTY; without even the implied warranty of 323 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 324 | GNU General Public License for more details. 325 | 326 | You should have received a copy of the GNU General Public License along 327 | with this program; if not, write to the Free Software Foundation, Inc., 328 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 329 | 330 | Also add information on how to contact you by electronic and paper mail. 331 | 332 | If the program is interactive, make it output a short notice like this 333 | when it starts in an interactive mode: 334 | 335 | Gnomovision version 69, Copyright (C) year name of author 336 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 337 | This is free software, and you are welcome to redistribute it 338 | under certain conditions; type `show c' for details. 339 | 340 | The hypothetical commands `show w' and `show c' should show the appropriate 341 | parts of the General Public License. Of course, the commands you use may 342 | be called something other than `show w' and `show c'; they could even be 343 | mouse-clicks or menu items--whatever suits your program. 344 | 345 | You should also get your employer (if you work as a programmer) or your 346 | school, if any, to sign a "copyright disclaimer" for the program, if 347 | necessary. Here is a sample; alter the names: 348 | 349 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 350 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 351 | 352 | , 1 April 1989 353 | Ty Coon, President of Vice 354 | 355 | This General Public License does not permit incorporating your program into 356 | proprietary programs. If your program is a subroutine library, you may 357 | consider it more useful to permit linking proprietary applications with the 358 | library. If this is what you want to do, use the GNU Lesser General 359 | Public License instead of this License. 360 | --------------------------------------------------------------------------------