Re: [go-nuts] Image Resize and Crop

2020-05-11 Thread Robert Engels
That’s assuming the image is displayed. It is easier to keep portions of the 
image on disk with certain formats (eg tiled). 

> On May 11, 2020, at 2:40 PM, Robert Engels  wrote:
> 
> That means there is a memory leak. Once an image is decoded it takes the 
> same amount of memory based on resolution and bit depth. 
> 
>> On May 11, 2020, at 11:59 AM, Vivi  wrote:
>> 
>> It will make sense when you change PNG to JPG and loop 100x to see the 
>> actual memory consumption with grtme -v ...
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/75693ebf-5476-4807-a54d-4a2ed4fca411%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2BC62DFB-33BD-4E31-A258-F52759433204%40ix.netcom.com.


Re: [go-nuts] Image Resize and Crop

2020-05-11 Thread Robert Engels
That means there is a memory leak. Once an image is decoded it takes the same 
amount of memory based on resolution and bit depth. 

> On May 11, 2020, at 11:59 AM, Vivi  wrote:
> 
> It will make sense when you change PNG to JPG and loop 100x to see the 
> actual memory consumption with grtme -v ...
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/75693ebf-5476-4807-a54d-4a2ed4fca411%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/028486BD-7630-4AF4-B3F1-6486C6629361%40ix.netcom.com.


Re: [go-nuts] Image Resize and Crop

2020-05-11 Thread Vivi
It will make sense when you change PNG to JPG and loop 100x to see the actual 
memory consumption with grtme -v ...

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/75693ebf-5476-4807-a54d-4a2ed4fca411%40googlegroups.com.


Re: [go-nuts] Image Resize and Crop

2020-05-11 Thread Robert Engels
I’m sorry but that makes no sense. Do you mean file size is smaller? Depends on 
jpeg compression options. It can be many times smaller than a png. 

> On May 11, 2020, at 10:22 AM, Vivi  wrote:
> 
> 
> 
> I found a snippet, memory usage with PNG vs JPG (more than 2x memory than PNG)
> https://gist.github.com/logrusorgru/570d64fd6a051e0441014387b89286ca
> 
> Why does JPG consume more memory?
> 
> Is it fine to have libvips as a dependency for content management system in 
> the same way as PHP require with Imagick or GD?
> 
> 
>> On Monday, 11 May 2020 18:35:47 UTC+8, Nick wrote:
>> Quoth Vivi: 
>> > How do you advice to resize and crop JPEG and PNG or probably WebP images 
>> > without rely on 3rd parties dependencies?
>> > 
>> > It was hard to find a good snippet or could be useful to have basic API 
>> > function in Go standard library since it's a common feature. 
>> 
>> I'd encourage you to consider trying to implement simple image 
>> manipulation algorithms yourself, if only for practice. I've found the 
>> interfaces in the image package really nice to work with, and have 
>> learned a lot implementing useful things myself based on them.   
>> There's a very good blog post about the package here: 
>> https://blog.golang.org/image 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/418137eb-52ee-433f-b45d-1a4b0a1c6c58%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/22278AC9-7E28-4078-A0C5-2F259B05F227%40ix.netcom.com.


Re: [go-nuts] Image Resize and Crop

2020-05-11 Thread Vivi

I found a snippet, memory usage with PNG vs JPG (more than 2x memory than 
PNG)
https://gist.github.com/logrusorgru/570d64fd6a051e0441014387b89286ca

Why does JPG consume more memory?

Is it fine to have libvips as a dependency for content management system in 
the same way as PHP require with Imagick or GD?


On Monday, 11 May 2020 18:35:47 UTC+8, Nick wrote:
>
> Quoth Vivi: 
> > How do you advice to resize and crop JPEG and PNG or probably WebP 
> images 
> > without rely on 3rd parties dependencies? 
> > 
> > It was hard to find a good snippet or could be useful to have basic API 
> > function in Go standard library since it's a common feature. 
>
> I'd encourage you to consider trying to implement simple image 
> manipulation algorithms yourself, if only for practice. I've found the 
> interfaces in the image package really nice to work with, and have 
> learned a lot implementing useful things myself based on them.   
> There's a very good blog post about the package here: 
> https://blog.golang.org/image 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/418137eb-52ee-433f-b45d-1a4b0a1c6c58%40googlegroups.com.


Re: [go-nuts] Image Resize and Crop

2020-05-11 Thread Nick
Quoth Vivi:
> How do you advice to resize and crop JPEG and PNG or probably WebP images
> without rely on 3rd parties dependencies?
> 
> It was hard to find a good snippet or could be useful to have basic API
> function in Go standard library since it's a common feature.

I'd encourage you to consider trying to implement simple image 
manipulation algorithms yourself, if only for practice. I've found the
interfaces in the image package really nice to work with, and have 
learned a lot implementing useful things myself based on them.  
There's a very good blog post about the package here: 
https://blog.golang.org/image

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/20200511103449.GA7516%40mussel.lan.


Re: [go-nuts] Image Resize and Crop

2020-05-11 Thread Randall O'Reilly
https://github.com/anthonynsimon/bild has parallel image ops of all sorts and 
is widely used & well supported.

- Randy

> On May 10, 2020, at 9:52 PM, robert engels  wrote:
> 
> I don’t know and I doubt anyone else does off the top of their head, so why 
> don’t you write a test and see?
> 
> Image processing is highly image and usage dependent, e.g. acceptable quality 
> vs. speed vs. memory.
> 
> Using non-quantifiable terms like “huge” is not testable nor verifiable.
> 
>> On May 10, 2020, at 9:50 PM, Vivi  wrote:
>> 
>> 
>> How does it compare to vipsthumbnail that utilize low memory usage which I 
>> believe it use horizontal threading, does Go's image/draw package consume 
>> large memory if the image source is huge?
>> 
>> 
>> On Monday, 11 May 2020 07:00:11 UTC+8, Nigel Tao wrote:
>> On Mon, May 11, 2020 at 4:28 AM robert engels  wrote: 
>> > All of the code to do scaling and cropping in the ‘image’ package in the 
>> > stdlib. 
>> 
>> Cropping is in the stdlib but scaling is not. Various scaling 
>> algorithms (e.g. nearest neighbor, Catmull-Rom) are in the 
>> golang.org/x/image/draw package instead. As 
>> https://godoc.org/golang.org/x/image/draw says, "This package is a 
>> superset of and a drop-in replacement for the image/draw package in 
>> the standard library". 
>> 
>> https://godoc.org/golang.org/x/image/draw#example-Draw has some example 
>> code. 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/b0443e9a-3edb-4bcb-b056-f11186188eb9%40googlegroups.com.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/4ECA0CE7-D503-4331-84CC-80EF1A85FB0B%40ix.netcom.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/5FC5A709-67C6-4CD5-A64C-6EA91454%40gmail.com.


Re: [go-nuts] Image Resize and Crop

2020-05-10 Thread robert engels
I don’t know and I doubt anyone else does off the top of their head, so why 
don’t you write a test and see?

Image processing is highly image and usage dependent, e.g. acceptable quality 
vs. speed vs. memory.

Using non-quantifiable terms like “huge” is not testable nor verifiable.

> On May 10, 2020, at 9:50 PM, Vivi  wrote:
> 
> 
> How does it compare to vipsthumbnail that utilize low memory usage which I 
> believe it use horizontal threading, does Go's image/draw package consume 
> large memory if the image source is huge?
> 
> 
> On Monday, 11 May 2020 07:00:11 UTC+8, Nigel Tao wrote:
> On Mon, May 11, 2020 at 4:28 AM robert engels > 
> wrote: 
> > All of the code to do scaling and cropping in the ‘image’ package in the 
> > stdlib. 
> 
> Cropping is in the stdlib but scaling is not. Various scaling 
> algorithms (e.g. nearest neighbor, Catmull-Rom) are in the 
> golang.org/x/image/draw  package instead. As 
> https://godoc.org/golang.org/x/image/draw 
>  says, "This package is a 
> superset of and a drop-in replacement for the image/draw package in 
> the standard library". 
> 
> https://godoc.org/golang.org/x/image/draw#example-Draw 
>  has some example 
> code. 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/b0443e9a-3edb-4bcb-b056-f11186188eb9%40googlegroups.com
>  
> .

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4ECA0CE7-D503-4331-84CC-80EF1A85FB0B%40ix.netcom.com.


Re: [go-nuts] Image Resize and Crop

2020-05-10 Thread robert engels
My bad, I didn’t read the API docs completely. Kind of a strange interface 
declaration in the stdlib image package - that there is only a single rectangle 
for Draw() and it is bounded by the two images.

> On May 10, 2020, at 5:57 PM, Nigel Tao  wrote:
> 
> On Mon, May 11, 2020 at 4:28 AM robert engels  wrote:
>> All of the code to do scaling and cropping in the ‘image’ package in the 
>> stdlib.
> 
> Cropping is in the stdlib but scaling is not. Various scaling
> algorithms (e.g. nearest neighbor, Catmull-Rom) are in the
> golang.org/x/image/draw package instead. As
> https://godoc.org/golang.org/x/image/draw says, "This package is a
> superset of and a drop-in replacement for the image/draw package in
> the standard library".
> 
> https://godoc.org/golang.org/x/image/draw#example-Draw has some example code.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CAOeFMNXO6J87er5Gw_m782qjP5OHhoAnnvTyLpPBv6C%2B%2B16eHA%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/20997C39-CEA7-4395-877F-7A61C659C468%40ix.netcom.com.


Re: [go-nuts] Image Resize and Crop

2020-05-10 Thread Nigel Tao
On Mon, May 11, 2020 at 4:28 AM robert engels  wrote:
> All of the code to do scaling and cropping in the ‘image’ package in the 
> stdlib.

Cropping is in the stdlib but scaling is not. Various scaling
algorithms (e.g. nearest neighbor, Catmull-Rom) are in the
golang.org/x/image/draw package instead. As
https://godoc.org/golang.org/x/image/draw says, "This package is a
superset of and a drop-in replacement for the image/draw package in
the standard library".

https://godoc.org/golang.org/x/image/draw#example-Draw has some example code.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOeFMNXO6J87er5Gw_m782qjP5OHhoAnnvTyLpPBv6C%2B%2B16eHA%40mail.gmail.com.


Re: [go-nuts] Image Resize and Crop

2020-05-10 Thread robert engels
All of the code to do scaling and cropping in the ‘image’ package in the 
stdlib. You ‘draw’ into a new image to do scaling. You use SubImage() to 
perform cropping. See https://blog.golang.org/image-draw

Alternatively, if you need more advanced scaling operations it would be fairly 
trivial to port the GIMP scaling operations to Go.

> On May 10, 2020, at 1:12 PM, Michael Jones  wrote:
> 
> I have an extremely elaborate resizing library, but it is so complex it would 
> not make sense as a standard tool for common uses. (Many convolution kernels, 
> separate windows, forward and backward mapping, separable convolutions, 
> upsampling first for Nyquist issues, strategy phase and then concurrent 
> filtering, etc. good work but over the top) 
> 
> If nothing else, you could port Paul Heckbert’s filter program from days of 
> yore. Check graphics gems. 
> 
> On Sun, May 10, 2020 at 9:36 AM Vivi  > wrote:
> How do you advice to resize and crop JPEG and PNG or probably WebP images 
> without rely on 3rd parties dependencies?
> 
> It was hard to find a good snippet or could be useful to have basic API 
> function in Go standard library since it's a common feature.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/89e32097-6aa0-48a4-b2ca-8d3756e26af3%40googlegroups.com
>  
> .
> -- 
> Michael T. Jones
> michael.jo...@gmail.com 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CALoEmQwOxRXsrB0%2B-oeAWB938A%2BOzCRppTQvrKENp9%3D8o3BcYQ%40mail.gmail.com
>  
> .

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/0BA4F6D5-0E95-465F-B32C-4F9602787BE6%40ix.netcom.com.


Re: [go-nuts] Image Resize and Crop

2020-05-10 Thread Michael Jones
I have an extremely elaborate resizing library, but it is so complex it
would not make sense as a standard tool for common uses. (Many convolution
kernels, separate windows, forward and backward mapping, separable
convolutions, upsampling first for Nyquist issues, strategy phase and then
concurrent filtering, etc. good work but over the top)

If nothing else, you could port Paul Heckbert’s filter program from days of
yore. Check graphics gems.

On Sun, May 10, 2020 at 9:36 AM Vivi  wrote:

> How do you advice to resize and crop JPEG and PNG or probably WebP images
> without rely on 3rd parties dependencies?
>
> It was hard to find a good snippet or could be useful to have basic API
> function in Go standard library since it's a common feature.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/89e32097-6aa0-48a4-b2ca-8d3756e26af3%40googlegroups.com
> 
> .
>
-- 

*Michael T. jonesmichael.jo...@gmail.com *

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CALoEmQwOxRXsrB0%2B-oeAWB938A%2BOzCRppTQvrKENp9%3D8o3BcYQ%40mail.gmail.com.


[go-nuts] Image Resize and Crop

2020-05-10 Thread Vivi
How do you advice to resize and crop JPEG and PNG or probably WebP images 
without rely on 3rd parties dependencies?

It was hard to find a good snippet or could be useful to have basic API 
function in Go standard library since it's a common feature.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/89e32097-6aa0-48a4-b2ca-8d3756e26af3%40googlegroups.com.