2017-09-25 141 views
0

我正在处理输入文件具有扩展名.tif(标记图像文件格式(TIFF))的应用程序。基本问题是在所有主流浏览器都不适用的浏览器中显示.tif文件。该解决方案我已经接受的是使用http://image.intervention.io/api/encode将它们转换成PNGtif到pdf/png enocoding

我已经很转化.tif文件为PNG在PHP 5.5 Laravel

图片干预是靠imagick为TIF编码,我已经安装了这个依赖,但编码方案是转换/显示/存储第一个图像从tif文件,而不是所有的文件。

任何人都可以使用任何PHP库从tif解决PNG或PDF转换?

回答

0

我的建议是:您必须使用gdal2tiles.py将.tif文件转换为.png。

gdal2tiles Documentation

当您运行此命令其创建一个输出文件夹,在其中你openlayers.html文件,打开它,看看在每个浏览器的.tif文件轻松。

如果您需要与此相关的任何帮助,请发表评论。我会指导你。

+0

感谢您的回复,但我的要求是用PHP,所以使Python脚本有点复杂 – Chintan7027

1

我觉得很不错article这里,解决这个问题的办法是,

$file = Storage::disk('s3')->get(request()->file_name); 
$file_pdf =storage_path("app/bundle/tmp/".end($name).".pdf"); 
$document =new \Imagick(); 
$document->readImageBlob($file); 
if (!$document->writeImages($file_pdf, true)) { 
    echo "Unable to write the file"; 
} else { 
    $document->clear(); 
} 
return response()->file($file_pdf)->deleteFileAfterSend(true); 

我一直在使用laravel存储读取文件的S3流,并通过使用Imagick readImageBlob()方法斑点。现有技术的状态是$document->writeImages("to_pdf.pdf")文件。最后你可以清除文件变量