導航:首頁 > 編程語言 > phpbmp轉jpg

phpbmp轉jpg

發布時間:2022-05-30 23:08:22

php向mysql資料庫存放圖片時可以存放bmp和gif類型,但不能存放png和jpg類型,請問為什麼

怎麼就不行呢?
肯定可以存放的。

⑵ 如何在php中打開bmp格式的圖片

如果擴展名不是故意該的話php是一個腳本語言文件。你可以用記事本打開看看裡面 如果確認是圖片 你可以把php改成jpg或png或bmp試試

⑶ php 轉換圖片格式問題

用下面代碼(PHP必須支持GD庫)
$input=上傳的BMP文件名
$output=要存的jpeg文件名
$image=imagecreatefromwbmp($input);
imagejpeg($image,$output);
imagedestroy($image);
unlink($input);
用GD庫還可以加水印、改大小等,網上都有,一搜就行。我是按照PHP手冊

⑷ 攝像頭拍的圖片是bmp格式,怎麼轉換成jpg格式呢

打開photoshop 然後打開你的BMP文件...在按 文件另存為 選擇你保存的地方 在下面在選擇你要保存的格式 如 JPG OK...

⑸ php上傳bmp圖片類型問題

imagecreatefromwbmp() 這個函數 不能針對bmp文件操作,因為兩個根本不是什麼相似的文件類型。

php5版本還沒有 imagecreatefrombmp() 這個函數(是bmp不是wbmp)
所以無法創建bmp圖像。

所以那啥,要麼你自己寫一個imagecreatefrombmp()進行擴展。
要麼就源文件上傳。

⑹ 哪裡有PHP圖片格式轉換成JPG或者BMP格式的圖片轉換工具下載啊

pnp的吧
你用畫圖打開
,然後另存為..就行了。不過存的時候要記得,把保存的圖片格式改成你
想要得就行了

⑺ PHP能壓縮網路上的圖片嗎

PHP圖片上傳並壓縮的實現方法具體內容如下使用到三個文件
connect.php:連接資料庫
test_upload.php:執行SQL語句
upload_img.php:上傳圖片並壓縮
三個文件代碼如下:
連接資料庫:connect.php
<?php
$db_host = '';
$db_user = '';
$db_psw = '';
$db_name = '';
$db_port = '';
$sqlconn=new mysqli($db_host,$db_user,$db_psw,$db_name);$q="set names utf8;";
$result=$sqlconn->query($q);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());exit();
}
?>
執行SQL語句:test_upload.php
<?php
require ("connect.php");
require ("upload_img.php");
$real_img=$uploadfile;
$small_img=$uploadfile_resize;
$insert_sql = "insert into img (real_img,small_img) values (?,?)";$result = $sqlconn -> prepare($insert_sql);$result -> bind_param("ss", $real_img,$small_img);$result -> execute();
?>
上傳圖片並壓縮:upload_img.php
<?php
//設置文件保存目錄
$uploaddir = "upfiles/";
//設置允許上傳文件的類型
$type=array("jpg","gif","bmp","jpeg","png");//獲取文件後綴名函數
function fileext($filename)
{
return substr(strrchr($filename, '.'), 1);}
//生成隨機文件名函數
function random($length)
{
$hash = 'CR-';
$chars = '';$max = strlen($chars) - 1;
mt_srand((double)microtime() * 1000000);
for($i = 0; $i < $length; $i++)
{
$hash .= $chars[mt_rand(0, $max)];
}
return $hash;
}
$a=strtolower(fileext($_FILES['filename']['name']));//判斷文件類型
if(!in_array(strtolower(fileext($_FILES['filename']['name'])),$type)){
$text=implode(",",$type);
$ret_code=3;//文件類型錯誤
$page_result=$text;
$retArray = array('ret_code' => $ret_code,'page_result'=>$page_result);$retJson = json_encode($retArray);
echo $retJson;
return;
}
//生成目標文件的文件名
else
{
$filename=explode(".",$_FILES['filename']['name']);do
{
$filename[0]=random(10); //設置隨機數長度$name=implode(".",$filename);
//$name1=$name.".Mcncc";
$uploadfile=$uploaddir.$name;
}
while(file_exists($uploadfile));
if (move_uploaded_file($_FILES['filename']['tmp_name'],$uploadfile)){
if(is_uploaded_file($_FILES['filename']['tmp_name'])){
$ret_code=1;//上傳失敗
}
else
{//上傳成功
$ret_code=0;
}
}
$retArray = array('ret_code' => $ret_code);$retJson = json_encode($retArray);
echo $retJson;
}
//壓縮圖片
$uploaddir_resize="upfiles_resize/";
$uploadfile_resize=$uploaddir_resize.$name;//$pic_width_max=120;
//$pic_height_max=90;
//以上與下面段注釋可以聯合使用,可以使圖片根據計算出來的比例壓縮$file_type=$_FILES["filename"]['type'];
function ResizeImage($uploadfile,$maxwidth,$maxheight,$name){
//取得當前圖片大小
$width = imagesx($uploadfile);
$height = imagesy($uploadfile);
$i=0.5;
//生成縮略圖的大小
if(($width > $maxwidth) || ($height > $maxheight)){
/*
$widthratio = $maxwidth/$width;
$heightratio = $maxheight/$height;
if($widthratio < $heightratio)
{
$ratio = $widthratio;
}
else
{
$ratio = $heightratio;
}
$newwidth = $width * $ratio;
$newheight = $height * $ratio;
*/
$newwidth = $width * $i;
$newheight = $height * $i;
if(function_exists("imageresampled")){
$uploaddir_resize = imagecreatetruecolor($newwidth, $newheight);imageresampled($uploaddir_resize, $uploadfile, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);}
else
{
$uploaddir_resize = imagecreate($newwidth, $newheight);imageresized($uploaddir_resize, $uploadfile, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);}
ImageJpeg ($uploaddir_resize,$name);
ImageDestroy ($uploaddir_resize);
}
else
{
ImageJpeg ($uploadfile,$name);
}
}
if($_FILES["filename"]['size'])
{
if($file_type == "image/pjpeg"||$file_type == "image/jpg"|$file_type == "image/jpeg"){
//$im = imagecreatefromjpeg($_FILES[$upload_input_name]['tmp_name']);$im = imagecreatefromjpeg($uploadfile);
}
elseif($file_type == "image/x-png")
{
//$im = imagecreatefrompng($_FILES[$upload_input_name]['tmp_name']);$im = imagecreatefromjpeg($uploadfile);
}
elseif($file_type == "image/gif")
{
//$im = imagecreatefromgif($_FILES[$upload_input_name]['tmp_name']);$im = imagecreatefromjpeg($uploadfile);
}
else//默認jpg
{
$im = imagecreatefromjpeg($uploadfile);
}
if($im)
{
ResizeImage($im,$pic_width_max,$pic_height_max,$uploadfile_resize);ImageDestroy ($im);
}
}
?>
請按照現實情況更改connect.php,test_upload.php中對應的信息

⑻ php格式的圖片怎樣轉換成bmp或其他格式的

大哥..PHP是動態網頁的格式,不是圖片格式...

那可能是用PHP生成出來的圖片...

例如
http://bbs.maxkiss.net/ck.php

這是一個PHP文件,可是打開他,生成的是一個PNG格式的圖片..

朋友請你清楚一點,,PHP不是圖片格式.

閱讀全文

與phpbmp轉jpg相關的資料

熱點內容
加密媒體怎麼輸密碼 瀏覽:161
方舟如何刪除伺服器數據 瀏覽:600
用閱讀app怎麼看18 瀏覽:689
gn文件編譯 瀏覽:783
酷閃加密系統 瀏覽:820
區塊鏈數據加密 瀏覽:389
3d命令集 瀏覽:289
單片機的智能產品工廠里有 瀏覽:300
事業單位程序員有必要去嗎 瀏覽:583
人工智慧訓練小鳥python 瀏覽:132
怎樣把兩個pdf合並成一個 瀏覽:681
什麼app帶仿製圖章 瀏覽:420
單片機CJNE什麼意思 瀏覽:569
廊坊伺服器是什麼 瀏覽:763
客戶解壓要打欠條還是收據 瀏覽:774
通過app組件啟動有什麼壞處 瀏覽:775
不屬於國產密碼演算法 瀏覽:861
單片機LED顯示字型檔 瀏覽:353
日本文件夾品牌十大名牌 瀏覽:397
靜脈壓縮襪和打底褲的區別 瀏覽:345