Sitelet https://github.com/documentcloud/docsplit/issues/62
Skip to content

Determining the paths of images created as a result of Docsplit.extract_images #62

Description

@hderms

It would be nice if there was an option one could pass which would determine whether the images created were returned, or the path to the PDF that was created as an intermediary. I'm thinking something like :and_return => :images

or :and_return => :intermediate

With the default case (:and_return == nil) being the current behavior. I believe this wouldn't break backwards compatibility, and would increase the utility of this application from within Ruby.

Activity

  1. knowtheory commented on Nov 8, 2012

    @knowtheory
    Member

    Hey @hderms, could you explain your use case a little further?

  2. hderms commented on Nov 8, 2012

    @hderms
    Author

    I think perhaps I was being a little unclear. If one's primary goal is to split a PDF or PPT, or whatever into a bunch of sequential images via the Docsplit.extract_images method, then perhaps it would be useful to have that method return the paths of all the images extracted, rather than the paths of the PDFs from @pdfs in ImageExtractor. The PDF is merely an intermediate step, as far as I know, and returning the paths to the images extracted is probably more useful in most cases.

    In my particular case, I have a Document model in rails, and I'd like it to have_many images. Programmatically receiving the paths to the images after extraction would be useful to me in setting up this relation.

  3. hderms commented on Nov 8, 2012

    @hderms
    Author

    I have a patch that implements this functionality like so:

    Docsplit.extract_images('/home/rvibe/Downloads/BadPresentations.ppt', :size => '1000x', :format => [:png, :jpg], :and_return => :images)
    => [["/home/rvibe/Lib/docsplit/BadPresentations_1.png", "/home/rvibe/Lib/docsplit/BadPresentations_2.png", "/home/rvibe/Lib/docsplit/BadPresentations_3.png", "/home/rvibe/Lib/docsplit/BadPresentations_4.png", "/home/rvibe/Lib/docsplit/BadPresentations_5.png", "/home/rvibe/Lib/docsplit/BadPresentations_6.png", "/home/rvibe/Lib/docsplit/BadPresentations_7.png"], ["/home/rvibe/Lib/docsplit/BadPresentations_1.jpg", "/home/rvibe/Lib/docsplit/BadPresentations_2.jpg", "/home/rvibe/Lib/docsplit/BadPresentations_3.jpg", "/home/rvibe/Lib/docsplit/BadPresentations_4.jpg", "/home/rvibe/Lib/docsplit/BadPresentations_5.jpg", "/home/rvibe/Lib/docsplit/BadPresentations_6.jpg", "/home/rvibe/Lib/docsplit/BadPresentations_7.jpg"]]

    Without using the :and_return=> :images option, the default behavior is preserved:

    Docsplit.extract_images('/home/rvibe/Downloads/BadPresentations.ppt', :size => '1000x', :format => [:png, :jpg])
    => ["/tmp/docsplit/BadPresentations.pdf"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions