导航:首页 > 编程语言 > 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相关的资料

热点内容
app内页面的网址怎么提取 浏览:286
安卓升级包pkg文件如何打开 浏览:77
id3算法原理 浏览:602
骑手通app怎么输入不了保单号 浏览:988
82一56的筒便算法 浏览:404
数控机床fanuc编程 浏览:607
天刀mode不是内部或外部命令 浏览:854
长城c30压缩机价格 浏览:1000
java打开图片文件 浏览:409
跟程序员聊天聊到半夜 浏览:411
自己怎么做app代码 浏览:915
win7旗舰版进不去带命令符 浏览:799
单片机温度检测电路 浏览:802
拼图软件不压缩 浏览:656
红袖添香小说源码 浏览:624
erp加密工具在哪里买 浏览:516
怎么给qq群里的文件加密 浏览:762
androidsetbitmap 浏览:597
mt4反向编译 浏览:201
sun服务器命令 浏览:827