Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 使用自定义过程调整图像大小_Image_Perl - Fatal编程技术网

Image 使用自定义过程调整图像大小

Image 使用自定义过程调整图像大小,image,perl,Image,Perl,我创建了一个小子程序,想知道需要添加什么才能调整几乎所有类型的图像大小: ###################### sub printImage($) { # be sure to do your error checking BEFORE calling this. it'll just # blindly rip along. my $fn = $_[0]; my $type = getType($fn); # see sub below my $buffer = "

我创建了一个小子程序,想知道需要添加什么才能调整几乎所有类型的图像大小:

######################
sub printImage($) {
  # be sure to do your error checking BEFORE calling this. it'll just
  # blindly rip along.
  my $fn = $_[0];
  my $type = getType($fn); # see sub below
  my $buffer = "";

  print "content-type: image/$type\n"; # these are awful, but ok for now
  print "\n"; # separate just in case we want to add more to the header.

  binmode STDOUT;

  open my $FH, "<", $fn or die "$!";
  while (read ($FH, $buffer, 10240)) {
    print $buffer; # prefer NOT to print as I read...
  }
  close $FH;

  # return $OUTPUT; # this would be better, no?
}
getType只查看文件扩展名,并返回扩展名


我想知道的是如何使用上述函数调整图像大小。我不想安装任何额外的模块或软件包,也不想做类似的事情。

此函数不处理图像内容,并且无法轻松转换为这样做。调整图像大小要比这复杂得多


因为你明确要求我们不要推荐额外的模块,所以我没有什么可以提供的。在纯Perl代码中调整图像的大小将非常缓慢,并且需要的代码远远超过我在回答中可能包含的代码。如果要对图像内容执行操作,如调整图像大小,请使用图像操作模块,如或。

,不要安装任何额外的模块或软件包,或执行类似操作。实际上,这是不可能的。那么,GD不是纯perl吗?我对它的内部结构一无所知。我只是用它,我不是在找容易的。GD做的…我问过,因为我使用的免费主机没有,也不会安装软件包…免费主机是…好吧,你可以得到你付的钱。如果您不能安装模块,Perl尤其无用;获得一个真正的web主机。lol。我有。我的家庭窗户盒子,现在。还没有对外开放。