Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ใครมี โค๊ต ของการย่อรูป มาเป็นThumbnails ที่จากรูปที่เป็นนามสกุล Bmp กับ TIFF มั้ง



 

ใครมี โค๊ต ของการย่อรูป มาเป็นThumbnails ที่จากรูปที่เป็นนามสกุล Bmp กับ TIFF มั้ง

 



Topic : 025609



โพสกระทู้ ( 41 )
บทความ ( 0 )



สถานะออฟไลน์




คือใน เว็บนี้สอบ แต่เป็น นามสกุล JPG อะคับ ถ้าเอารูปที่ไม่ใช่ JPG จะ Error คับ

$images_orig = ImageCreateFromJPEG($images); <--- Jpg


ใครบอกผมที่ค๊าบ



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-03-19 17:13:29 By : sacrifices View : 1083 Reply : 5
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

น่าจะไมีมี function รองรับน่ะครับ หรือไม่ลองผ่านใน Manual ดูน่ะครับ






Date : 2009-03-20 07:23:22 By : webmaster
 


 

No. 2



โพสกระทู้ ( 41 )
บทความ ( 0 )



สถานะออฟไลน์


แล้วมันพอมีภาษาไรช่วยทำได้ไหมคับ

แล้วที่แบบ Manual มันทำไงง่าคับ ช่วยอธิบาย หลักการคราวๆ ทีจิ
Date : 2009-03-20 15:37:39 By : sacrifices
 

 

No. 3



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


Convert bmp to jpg
Date : 2009-03-21 00:26:18 By : plakrim
 


 

No. 4



โพสกระทู้ ( 41 )
บทความ ( 0 )



สถานะออฟไลน์


ขอคุณคร้าบ
Date : 2009-03-23 16:24:53 By : sacrifices
 


 

No. 5

Guest


Code (PHP)
<?php

/**
 *
 * @convert BMP to GD
 *
 * @param string $src
 *
 * @param string|bool $dest
 *
 * @return bool
 *
 */
function bmp2gd($src, $dest = false)
{
    /*** try to open the file for reading ***/
    if(!($src_f = fopen($src, "rb")))
    {
        return false;
    }

/*** try to open the destination file for writing ***/
if(!($dest_f = fopen($dest, "wb")))
    {
        return false;
    }

/*** grab the header ***/
$header = unpack("vtype/Vsize/v2reserved/Voffset", fread( $src_f, 14));

/*** grab the rest of the image ***/
$info = unpack("Vsize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vncolor/Vimportant",
fread($src_f, 40));

/*** extract the header and info into varibles ***/
extract($info);
extract($header);

/*** check for BMP signature ***/
if($type != 0x4D42)
{
    return false;
}

/*** set the pallete ***/
$palette_size = $offset - 54;
$ncolor = $palette_size / 4;
$gd_header = "";

/*** true-color vs. palette ***/
$gd_header .= ($palette_size == 0) ? "\xFF\xFE" : "\xFF\xFF";
$gd_header .= pack("n2", $width, $height);
$gd_header .= ($palette_size == 0) ? "\x01" : "\x00";
if($palette_size) {
$gd_header .= pack("n", $ncolor);
}
/*** we do not allow transparency ***/
$gd_header .= "\xFF\xFF\xFF\xFF";

/*** write the destination headers ***/
fwrite($dest_f, $gd_header);

/*** if we have a valid palette ***/
if($palette_size)
{
    /*** read the palette ***/
    $palette = fread($src_f, $palette_size);
    /*** begin the gd palette ***/
    $gd_palette = "";
    $j = 0;
    /*** loop of the palette ***/
    while($j < $palette_size)
    {
        $b = $palette{$j++};
        $g = $palette{$j++};
        $r = $palette{$j++};
        $a = $palette{$j++};
        /*** assemble the gd palette ***/
        $gd_palette .= "$r$g$b$a";
    }
    /*** finish the palette ***/
    $gd_palette .= str_repeat("\x00\x00\x00\x00", 256 - $ncolor);
    /*** write the gd palette ***/
    fwrite($dest_f, $gd_palette);
}

/*** scan line size and alignment ***/
$scan_line_size = (($bits * $width) + 7) >> 3;
$scan_line_align = ($scan_line_size & 0x03) ? 4 - ($scan_line_size & 0x03) : 0;

/*** this is where the work is done ***/
for($i = 0, $l = $height - 1; $i < $height; $i++, $l--)
{
    /*** create scan lines starting from bottom ***/
    fseek($src_f, $offset + (($scan_line_size + $scan_line_align) * $l));
    $scan_line = fread($src_f, $scan_line_size);
    if($bits == 24)
    {
        $gd_scan_line = "";
        $j = 0;
        while($j < $scan_line_size)
        {
            $b = $scan_line{$j++};
            $g = $scan_line{$j++};
            $r = $scan_line{$j++};
            $gd_scan_line .= "\x00$r$g$b";
        }
    }
    elseif($bits == 8)
    {
        $gd_scan_line = $scan_line;
    }
    elseif($bits == 4)
    {
        $gd_scan_line = "";
        $j = 0;
        while($j < $scan_line_size)
        {
            $byte = ord($scan_line{$j++});
            $p1 = chr($byte >> 4);
            $p2 = chr($byte & 0x0F);
            $gd_scan_line .= "$p1$p2";
        }
        $gd_scan_line = substr($gd_scan_line, 0, $width);
    }
    elseif($bits == 1)
    {
        $gd_scan_line = "";
        $j = 0;
        while($j < $scan_line_size)
        {
            $byte = ord($scan_line{$j++});
            $p1 = chr((int) (($byte & 0x80) != 0));
            $p2 = chr((int) (($byte & 0x40) != 0));
            $p3 = chr((int) (($byte & 0x20) != 0));
            $p4 = chr((int) (($byte & 0x10) != 0));
            $p5 = chr((int) (($byte & 0x08) != 0));
            $p6 = chr((int) (($byte & 0x04) != 0));
            $p7 = chr((int) (($byte & 0x02) != 0));
            $p8 = chr((int) (($byte & 0x01) != 0));
            $gd_scan_line .= "$p1$p2$p3$p4$p5$p6$p7$p8";
        }
    /*** put the gd scan lines together ***/
    $gd_scan_line = substr($gd_scan_line, 0, $width);
    }
    /*** write the gd scan lines ***/
    fwrite($dest_f, $gd_scan_line);
}
/*** close the source file ***/
fclose($src_f);
/*** close the destination file ***/
fclose($dest_f);

return true;
}

/**
 *
 * @ceate a BMP image
 *
 * @param string $filename
 *
 * @return bin string on success
 *
 * @return bool false on failure
 *
 */
function ImageCreateFromBmp($filename)
{
    /*** create a temp file ***/
    $tmp_name = tempnam("/tmp", "GD");
    /*** convert to gd ***/
    if(bmp2gd($filename, $tmp_name))
    {
        /*** create new image ***/
        $img = imagecreatefromgd($tmp_name);
        /*** remove temp file ***/
        unlink($tmp_name);
        /*** return the image ***/
        return $img;
    }
    return false;
}

/*** example usage ***/

/*** read in the BMP image ***/
$img = ImageCreateFromBmp("test.bmp");
/*** write the new jpeg image ***/
imagejpeg($img, "test/test.jpg");

?>

Date : 2009-03-23 16:33:31 By : ตาม link
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ใครมี โค๊ต ของการย่อรูป มาเป็นThumbnails ที่จากรูปที่เป็นนามสกุล Bmp กับ TIFF มั้ง
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่