ecshop后台添加商品相册的时候bmp格式的无法生成缩略图
ecshop后台批量生成图片商品相册的时候bmp格式的无法生成缩略图求怎么解决? 我想达到的效果就是能够生成bmp格式的图片!
------解决方案--------------------
ecshop本身不支持bmp图像生成缩微图。你要先转换为gif/jpg/png其中一种
------解决方案--------------------
你可下载一个 ImageCreateFromBMP.php
然后改一下你的程序
------解决方案--------------------
function ImageCreateFromBMP( $filename ) { <br> // Ouverture du fichier en mode binaire <br> if ( ! $f1 = @fopen ($filename, "rb")) return FALSE ; <br> // 1 : Chargement des ent?tes FICHIER <br> $FILE = unpack ( "vfile_type/Vfile_size/Vreserved/Vbitmap_offset" , fread($f1 ,14)); <br> if ( $FILE ['file_type'] != 19778 ) return FALSE ; <br> // 2 : Chargement des ent?tes BMP <br> $BMP = unpack ( 'Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel' . <br> '/Vcompression/Vsize_bitmap/Vhoriz_resolution' . <br> '/Vvert_resolution/Vcolors_used/Vcolors_important' , fread ( $f1 , 40 )); <br> $BMP [ 'colors' ] = pow ( 2 , $BMP['bits_per_pixel ' ]); <br> if ( $BMP ['size_bitmap'] == 0 ) $BMP ['size_bitmap']=$FILE ['file_size']-$FILE ['bitmap_offset']; <br> $BMP ['bytes_per_pixel'] = $BMP ['bits_per_pixel'] / 8 ; <br> $BMP ['bytes_per_pixel2'] = ceil ( $BMP ['bytes_per_pixel']); <br> $BMP ['decal'] = ( $BMP ['width']*$BMP ['bytes_per_pixel'] / 4 ); <br> $BMP ['decal'] -= floor ( $BMP ['width'] * $BMP ['bytes_per_pixel'] / 4 ); <br> $BMP ['decal'] = 4 - ( 4 * $BMP ['decal']); <br> if ( $BMP ['decal'] == 4 ) $BMP ['decal'] = 0 ; <br> // 3 : Chargement des couleurs de la palette <br> $PALETTE = array (); <br> if ( $BMP ['colors'] $PALETTE = unpack ( 'V' . $BMP ['colors'] , fread ( $f1 , $BMP ['colors'] * 4 )); <br> } <br> // 4 : Cr?ation de l'image <br> $IMG = fread ( $f1 , $BMP ['size_bitmap']); <br> $VIDE = chr ( 0 ); <br> $res = imagecreatetruecolor( $BMP ['width'] , $BMP ['height']); <br> $P = 0 ; <br> $Y = $BMP ['height'] - 1 ; <br> while ( $Y >= 0 ){ <br> $X = 0 ; <br> while ( $X if ( $BMP ['bits_per_pixel'] == 24 ) <br> $COLOR = @unpack ( "V" , substr($IMG,$P,3).$VIDE ); <br> elseif ( $BMP['bits_per_pixel']== 16 ){ <br> $COLOR = unpack ( "n" , substr ( $IMG , $P , 2 )); <br> $COLOR [1] = $PALETTE [ $COLOR [ 1 ] + 1 ]; <br> }elseif ( $BMP['bits_per_pixel']== 8 ){ <br> $COLOR = unpack ( "n" , $VIDE . substr ( $IMG , $P , 1 )); <br> $COLOR [1] = $PALETTE [ $COLOR [ 1 ] + 1 ]; <br> }elseif ( $BMP['bits_per_pixel']== 4 ){ <br> $COLOR = unpack ( "n" , $VIDE . substr ( $IMG , floor ( $P ) , 1 )); <br> if (( $P * 2 ) % 2 == 0 ) <br> $COLOR [1] = ( $COLOR [1] >> 4 ) ; <br> else <br> $COLOR [1] = ( $COLOR [1] & 0x0F ); <br> $COLOR [1] = $PALETTE [ $COLOR [1] + 1 ]; <br> }elseif ( $BMP['bits_per_pixel']== 1 ){ <br> $COLOR = unpack ( "n" , $VIDE . substr ( $IMG , floor ( $P ) , 1 )); <br> if (( $P * 8 ) % 8 == 0 ) $COLOR [ 1 ] = $COLOR [ 1 ] >> 7 ; <br> elseif (( $P * 8 ) % 8 == 1 ) $COLOR [1] = ( $COLOR [1] & 0x40 ) >> 6 ; <br> elseif (( $P * 8 ) % 8 == 2 ) $COLOR [1] = ( $COLOR [1] & 0x20 ) >> 5 ; <br> elseif (( $P * 8 ) % 8 == 3 ) $COLOR [1] = ( $COLOR [1] & 0x10 ) >> 4 ; <div class="clear"> </div>