imalhasaranga / PDFLib

Current Release provide you methods to convert PDF to Images as well as Images to PDF, future releases will included more functions to interact with PDF files
MIT License
58 stars 37 forks source link

target image file name is fixed to "page-" #13

Closed vtsoft closed 5 years ago

vtsoft commented 5 years ago

Hi,

Thank you for this great conversion utility.

I just like to ask if it is possible to pass a "target file name for the converted images" maybe in the next version?

example:

 function convert($filename); // without extension

       $image_path = $this->output_path."/".$filename."-%d.".$this->imageExtention;

       $fileArray[] = $filename."-$i.".$this->imageExtention;

Thanks in advance

imalhasaranga commented 5 years ago

@mablae @ahfeel @joshbmarshall guys can you please see this something we should implement ?

mablae commented 5 years ago

it would be a nice enhancement.

However it needs to be done in a BC secure way or implies new major Version with this approach. (New param would break BC)

Instead introducing an new parameter on convert method it could be done with a new setter method setFilenamePattern defaulting to current pattern.

It also needs to be checked to contain page parameter and then use sprintf to fill the page number later on. This way we could have 01-page.pdf, too.

Let me know what you think.

joshbmarshall commented 5 years ago

You'd definitely do it in the way you currently set resolution - by adding as a setter method. So the default would be page- and the function would let you override. No BC issues then as @mablae suggested. That should be fairly straightforward to implement and use.

Going on conventions of other software I doubt we need to have the page number configurable in the image file name.

Do you want a pull request?

imalhasaranga commented 5 years ago

I think I agree with @mablae too, it is the way to go! @joshbmarshall please go ahead if you have time

joshbmarshall commented 5 years ago

pull request has been submitted #14

imalhasaranga commented 5 years ago

Can anyone review @joshbmarshall 's code and merge it and create tag for release version 1.2.2, if all are busy I'll have a look at this tonight and probably merge it.. please make sure Tests are passing

joshbmarshall commented 5 years ago

I just added to the pull request, some PHPDoc and add method chaining to allow end users have cleaner code.

imalhasaranga commented 5 years ago

@joshbmarshall thanks for the great work!!!

joshbmarshall commented 5 years ago

@imalhasaranga there is one test not passing on the current master with Ghostscript v9.26 on linux - PDFLibTest::testImageToPdf

imalhasaranga commented 5 years ago

hmm! we should find the root case and fix it, I mean tests are the only way we know that nothing has broken.. probably this may be an issue existed from the begining and no one noticed it

imalhasaranga commented 5 years ago

sorry release should be v1.2.3

joshbmarshall commented 5 years ago

I have found the issue with the gs on linux, putting in a fix now will add to the pull request

joshbmarshall commented 5 years ago

Done, please check tests pass on windows. They all pass on Alpine Linux with PHP7.3.2

vtsoft commented 5 years ago

Thank you for adding this feature. I really needed this. If it is okay to ask, when would it be the next release for version 1.2.3 be available?

Thanks again and more power to you guys who made this amazing conversion utility.

mablae commented 5 years ago

Since this is a new feature I would release as v1.3.0

imalhasaranga commented 5 years ago

@vtsoft v1.3.0 is released, @mablae agreed!! @joshbmarshall awesome work mate!!! cheers

vtsoft commented 5 years ago

@imalhasaranga, @mablae, @joshbmarshall,

Guys, Thanks for the quick release of the new version. It's really a great help. So far, I'm starting to test/apply on the ff. platforms: was able to test it in windows 10 pro, and it works like a charm. no issue encountered so far. will test it in CentOs 6.8. but still looking for the right package and version to use on Ghostscript.

If not too much to ask, I just like to know the link to which version of Ghostscript did you use in CentOs 6.8 during your testing.

Thanks again and more power to you guys. I know for sure that this is the right place to ask.

joshbmarshall commented 5 years ago

@vtsoft I have not used CentOS 6 for over 4 years. Even CentOS 7 has too old a version. You just need gs version 9.16 or newer. I tested with v9.26. Maybe you can use the GPL linux binaries from https://ghostscript.com/download/gsdnld.html

vtsoft commented 5 years ago

@joshbmarshall Thank you for your help. PDFlib using Ghostscript is now running in CentOs server.

and Thanks again all of you guys.