Load image from URL#32
Conversation
|
@goeh yeah, I think the url attribute is a great idea. I'll take a closer look at the code and leave some comments. You weren't kidding about the PRs. Great stuff! 👍 |
| work.call(new ByteArrayInputStream(imageData)) | ||
| } | ||
|
|
||
| String getHash() { |
There was a problem hiding this comment.
Nice! Definitely a more appropriate place for this code!
There was a problem hiding this comment.
@craigburke What do you think about the Arrays.copyOf(...) ? Am I being to paranoid about mutability? I wanted to write safe code but on the other hand I don't want to waste memory. I'm sure someone will create documents with lots of images.
Another related question is about if the first access to url should store the bytes in imageData. That way you only get one network request even when you use the image multiple times in a document. My current impl request the image bytes from the url every time you call getData().
|
I started yesterday with what I think is the most complicated document in this sprint. And I'm almost finished today. I'm on page 12 of 14. :) There are some minor adjustments and feature requests though. I like to discuss them with you. What is your preferred way for discussions, github issues, email? |
|
@goeh great! I'd love to discuss! Whatever works for you.... if you're on the Grails slack that might be easiest (https://grails.slack.com/), or twitter would work (https://twitter.com/craigburke1) too. Github issues are fine too but I'm pretty terrible about responding to emails. |
Added support for specifying url: "http://foo.com/images/logo.png" in the image element.
I'm not 100% sure that the Image class should have this URL loading responsibility, but it's very convenient to be able to specify an URL directly in the builder DSL.
I also made it possible to specify either image width or height and the other value will be calculated based on image dimensions. Before my change it would take both width and height from the image metadata if you did not specify both width and height.
Now you can do like this: image(url: "http://foo.com/images/logo.png", width: 5.inch) and the height will be set with correct aspect ratio.