Skip to content

ImageList#collect overrides Enumerable#collect #235

@vjustov

Description

@vjustov

Hello, first of all i want to thank you for your work with this gem.

I'm opening this issue in the hopes of opening a discussion as to why this is happening or at least get some guidance of what I'm doing wrong.
Right now, what I'm trying to achieve, is converting each the pages of a remote pdf to png,
for that, currently im doing this:

pdf_blob = open(pdf_url).read;
pdf_pages = Magick::ImageList.new.from_blob(pdf_blob) {
  self.density = 200
}.to_a.map { |page|
  page.to_blob { format = 'PNG' } 
}

I have tried several different approachs to accomplish the task:

  • Trying to set the format in the options block from the #from_blob method call
  • Calling collect after calling the the #from_blob method and calling to_blob on each page.

The last one brings me to the question: Why doesnt '#collect' mimic the api set by Enumerable? it returns an ImageList instead, and doesn't let us do something like:
Magick::ImageList.new.from_blob(pdf_blob) {self.density = 200}.collect { |page| page.to_blob { format = 'PNG'} } seems like a waste of resources.

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