简体   繁体   English

如何在Java中的特定位置创建具有特定高度和宽度的图像文件

[英]How to create image file in specific location with particular height and width in java

I am implementing the project where i am detecting rectangular object from image. 我正在实施从图像中检测矩形对象的项目。 I want to store that part to memory. 我想将该部分存储到内存中。 As the height and width every time i get is not predictable, i am not getting how to store that part of matrix by creating the image file at sd card that will exactly occupy the rectangular object 由于每次获取的高度和宽度都是不可预测的,因此我无法通过在sd卡上创建将完全占据矩形对象的图像文件来获取如何存储矩阵的那部分

how can i create image eg . 我如何创建图像,例如。 demo.jpg in //temp/ of size 90x50 // temp /中的demo.jpg,大小为90x50

use php GD function. 使用php GD函数。 use code like below 使用如下代码

header ('Content-Type: image/png');
$im = @imagecreatetruecolor(120, 20)
  or die('Cannot Initialize new GD image stream');
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);
imagepng($im);
imagedestroy($im);

take help from http://php.net/manual/en/function.set-error-handler.php http://php.net/manual/en/function.set-error-handler.php获取帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM