Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening pdf file #51

Open
web-apply opened this issue Feb 23, 2022 · 5 comments
Open

Opening pdf file #51

web-apply opened this issue Feb 23, 2022 · 5 comments

Comments

@web-apply
Copy link

web-apply commented Feb 23, 2022

Hello, I am new to php-vips add on.
This functions working good.
$x = vips_image_new_from_file($file)["out"]; (any files tpyes jpg, png, pdf)
vips_image_write_to_file($x, "temp/$filename-to.png",["Q"=>90);

But how can I custom read load $img=vips_pdfload() or $img=vips_pngload() with php plugin.

$img=vips_call("pdfload","file.pdf"); not working; How can i use spefic 300 operations on php ?

8.12.2 Active php ext functions;

  | (
  | [0] => vips_image_new_from_file
  | [1] => vips_image_new_from_buffer
  | [2] => vips_image_new_from_array
  | [3] => vips_image_write_to_file
  | [4] => vips_image_write_to_buffer
  | [5] => vips_image_copy_memory
  | [6] => vips_image_new_from_memory
  | [7] => vips_image_write_to_memory
  | [8] => vips_image_write_to_array
  | [9] => vips_foreign_find_load
  | [10] => vips_foreign_find_load_buffer
  | [11] => vips_interpolate_new
  | [12] => vips_call
  | [13] => vips_image_get
  | [14] => vips_image_get_typeof
  | [15] => vips_image_set
  | [16] => vips_type_from_name
  | [17] => vips_image_set_type
  | [18] => vips_image_remove
  | [19] => vips_error_buffer
  | [20] => vips_cache_set_max
  | [21] => vips_cache_set_max_mem
  | [22] => vips_cache_set_max_files
  | [23] => vips_concurrency_set
  | [24] => vips_cache_get_max
  | [25] => vips_cache_get_max_mem
  | [26] => vips_cache_get_max_files
  | [27] => vips_cache_get_size
  | [28] => vips_concurrency_get
  | [29] => vips_version
  | )

@jcupitt
Copy link
Member

jcupitt commented Feb 23, 2022

Hello @web-apply,

Don't use php-vips-ext directly! You need php-vips:

https://github.com/libvips/php-vips

It has a stable, documented and supported API.

We are removing php-vips-ext soon. If you use it directly, all your code will vanish, like tears in the rain.

@web-apply
Copy link
Author

web-apply commented Feb 24, 2022

@jcupitt Well https://github.com/libvips/php-vips library
Doesn't it work based on https://github.com/libvips/php-vips-ext plugin? How will php-vips work when php-vips-ext is removed?

@web-apply
Copy link
Author

web-apply commented Feb 24, 2022

I want to use pecl vips command functions directly. I'm doing photo conversions with simple php vips. The php-vips class contains a lot of code and I need lightweight code.

https://github.com/libvips/php-vips/blob/a5fcbd7d6f5fde27d749fb2bdf59749e31d42910/src/Image.php
.....******
public static function newFromFile(
string $filename,
array $options = []
): Image {
Utils::debugLog('newFromFile', [
'instance' => null,
'arguments' => [$filename, $options]
]);
$options = self::unwrap($options);
$result = vips_image_new_from_file($filename, $options);
self::errorIsArray($result);
$result = self::wrapResult($result);
Utils::debugLog('newFromFile', ['result' => $result]);
return $result; }
........

php-vips using vips function commands list.

@jcupitt
Copy link
Member

jcupitt commented Feb 24, 2022

We're switching to the new PHP FFI module. php-vips will use that to call into libvips directly, with no need for a binary module like php-vips-ext. It should make maintenance and deployment much simpler.

The branch is here if you're curious:

https://github.com/libvips/php-vips/tree/switch-to-php-ffi

It's almost done, just one segv left to fix.

@jcupitt
Copy link
Member

jcupitt commented Feb 24, 2022

php-vips isn't so heavy, is it? It's only a few thousand lines of code. The core of the new FFI version is under 1,000 lines for the whole of libvips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants