2019-01-02 11:58:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Copyright 2019 The Hugo Authors. All rights reserved. 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Licensed under the Apache License, Version 2.0 (the "License"); 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// you may not use this file except in compliance with the License. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// You may obtain a copy of the License at 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// http://www.apache.org/licenses/LICENSE-2.0 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Unless required by applicable law or agreed to in writing, software 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// distributed under the License is distributed on an "AS IS" BASIS, 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// See the License for the specific language governing permissions and 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// limitations under the License. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-01-02 11:58:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								package   resources 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import   ( 
  
						 
					
						
							
								
									
										
										
										
											2023-02-11 16:20:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "context" 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									 "fmt" 
  
						 
					
						
							
								
									
										
										
										
											2019-10-07 12:35:00 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "image" 
  
						 
					
						
							
								
									
										
										
										
											2022-06-11 18:52:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "image/gif" 
  
						 
					
						
							
								
									
										
										
										
											2023-03-01 09:34:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "io/fs" 
  
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:27:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "math/big" 
  
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "math/rand" 
  
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "os" 
  
						 
					
						
							
								
									
										
										
										
											2019-09-03 10:36:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "path" 
  
						 
					
						
							
								
									
										
										
										
											2018-03-14 09:33:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "path/filepath" 
  
						 
					
						
							
								
									
										
										
										
											2019-10-07 12:35:00 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "runtime" 
  
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "strconv" 
  
						 
					
						
							
								
									
										
										
										
											2022-06-11 18:52:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "strings" 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "sync" 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									 "testing" 
  
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:27:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "time" 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 09:34:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "github.com/gohugoio/hugo/resources/images/webp" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-18 10:27:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "github.com/gohugoio/hugo/common/paths" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:57:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "github.com/spf13/afero" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "github.com/disintegration/gift" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 "github.com/gohugoio/hugo/helpers" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "github.com/gohugoio/hugo/media" 
  
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "github.com/gohugoio/hugo/resources/images" 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "github.com/google/go-cmp/cmp" 
  
						 
					
						
							
								
									
										
										
										
											2018-02-19 16:34:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 "github.com/gohugoio/hugo/htesting/hqt" 
  
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 qt   "github.com/frankban/quicktest" 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var   eq   =   qt . CmpEquals ( 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 cmp . Comparer ( func ( p1 ,   p2   * resourceAdapter )   bool   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 return   p1 . resourceAdapterInner   ==   p2 . resourceAdapterInner 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ) , 
  
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 cmp . Comparer ( func ( p1 ,   p2   os . FileInfo )   bool   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 return   p1 . Name ( )   ==   p2 . Name ( )   &&   p1 . Size ( )   ==   p2 . Size ( )   &&   p1 . IsDir ( )   ==   p2 . IsDir ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ) , 
  
						 
					
						
							
								
									
										
										
										
											2023-03-01 09:34:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 cmp . Comparer ( func ( d1 ,   d2   fs . DirEntry )   bool   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 p1 ,   err1   :=   d1 . Info ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 p2 ,   err2   :=   d2 . Info ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 if   err1   !=   nil   ||   err2   !=   nil   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 return   false 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 return   p1 . Name ( )   ==   p2 . Name ( )   &&   p1 . Size ( )   ==   p2 . Size ( )   &&   p1 . IsDir ( )   ==   p2 . IsDir ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ) , 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 cmp . Comparer ( func ( p1 ,   p2   * genericResource )   bool   {   return   p1   ==   p2   } ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 cmp . Comparer ( func ( m1 ,   m2   media . Type )   bool   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 return   m1 . Type ( )   ==   m2 . Type ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ) , 
  
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:27:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 cmp . Comparer ( 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 func ( v1 ,   v2   * big . Rat )   bool   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 return   v1 . RatString ( )   ==   v2 . RatString ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 cmp . Comparer ( func ( v1 ,   v2   time . Time )   bool   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 return   v1 . Unix ( )   ==   v2 . Unix ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ) , 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								) 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-21 17:21:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func   TestImageTransformBasic ( t   * testing . T )   { 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c   :=   qt . New ( t ) 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 image   :=   fetchSunset ( c ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 fileCache   :=   image . ( specProvider ) . getSpec ( ) . FileCaches . ImageCache ( ) . Fs 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-21 10:59:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assertWidthHeight   :=   func ( img   images . ImageResource ,   w ,   h   int )   { 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 c . Helper ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( img ,   qt . Not ( qt . IsNil ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( img . Width ( ) ,   qt . Equals ,   w ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( img . Height ( ) ,   qt . Equals ,   h ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 16:24:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 colors ,   err   :=   image . Colors ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( colors ,   qt . DeepEquals ,   [ ] string { "#2d2f33" ,   "#a49e93" ,   "#d39e59" ,   "#a76936" ,   "#737a84" ,   "#7c838b" } ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( image . RelPermalink ( ) ,   qt . Equals ,   "/a/sunset.jpg" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( image . ResourceType ( ) ,   qt . Equals ,   "image" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assertWidthHeight ( image ,   900 ,   562 ) 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 resized ,   err   :=   image . Resize ( "300x200" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( image   !=   resized ,   qt . Equals ,   true ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( image ,   qt . Not ( eq ) ,   resized ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 assertWidthHeight ( resized ,   300 ,   200 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 assertWidthHeight ( image ,   900 ,   562 ) 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 resized0x ,   err   :=   image . Resize ( "x200" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assertWidthHeight ( resized0x ,   320 ,   200 ) 
  
						 
					
						
							
								
									
										
										
										
											2019-09-03 10:36:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assertFileCache ( c ,   fileCache ,   path . Base ( resized0x . RelPermalink ( ) ) ,   320 ,   200 ) 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 resizedx0 ,   err   :=   image . Resize ( "200x" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assertWidthHeight ( resizedx0 ,   200 ,   125 ) 
  
						 
					
						
							
								
									
										
										
										
											2019-09-03 10:36:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assertFileCache ( c ,   fileCache ,   path . Base ( resizedx0 . RelPermalink ( ) ) ,   200 ,   125 ) 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 resizedAndRotated ,   err   :=   image . Resize ( "x200 r90" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assertWidthHeight ( resizedAndRotated ,   125 ,   200 ) 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assertWidthHeight ( resized ,   300 ,   200 ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( resized . RelPermalink ( ) ,   qt . Equals ,   "/a/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x200_resize_q68_linear.jpg" ) 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 fitted ,   err   :=   resized . Fit ( "50x50" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( fitted . RelPermalink ( ) ,   qt . Equals ,   "/a/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_625708021e2bb281c9f1002f88e4753f.jpg" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assertWidthHeight ( fitted ,   50 ,   33 ) 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 // Check the MD5 key threshold 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 fittedAgain ,   _   :=   fitted . Fit ( "10x20" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 fittedAgain ,   err   =   fittedAgain . Fit ( "10x20" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( fittedAgain . RelPermalink ( ) ,   qt . Equals ,   "/a/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_3f65ba24dc2b7fba0f56d7f104519157.jpg" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assertWidthHeight ( fittedAgain ,   10 ,   7 ) 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 filled ,   err   :=   image . Fill ( "200x100 bottomLeft" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( filled . RelPermalink ( ) ,   qt . Equals ,   "/a/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_200x100_fill_q68_linear_bottomleft.jpg" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assertWidthHeight ( filled ,   200 ,   100 ) 
  
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-02-03 16:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 smart ,   err   :=   image . Fill ( "200x100 smart" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( smart . RelPermalink ( ) ,   qt . Equals ,   fmt . Sprintf ( "/a/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_200x100_fill_q68_linear_smart%d.jpg" ,   1 ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 assertWidthHeight ( smart ,   200 ,   100 ) 
  
						 
					
						
							
								
									
										
										
										
											2018-02-03 16:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									 // Check cache 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 filledAgain ,   err   :=   image . Fill ( "200x100 bottomLeft" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( filled ,   eq ,   filledAgain ) 
  
						 
					
						
							
								
									
										
										
										
											2022-02-22 16:50:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 cropped ,   err   :=   image . Crop ( "300x300 topRight" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( cropped . RelPermalink ( ) ,   qt . Equals ,   "/a/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x300_crop_q68_linear_topright.jpg" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 assertWidthHeight ( cropped ,   300 ,   300 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 smartcropped ,   err   :=   image . Crop ( "200x200 smart" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( smartcropped . RelPermalink ( ) ,   qt . Equals ,   fmt . Sprintf ( "/a/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_200x200_crop_q68_linear_smart%d.jpg" ,   1 ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 assertWidthHeight ( smartcropped ,   200 ,   200 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 // Check cache 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 croppedAgain ,   err   :=   image . Crop ( "300x300 topRight" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( cropped ,   eq ,   croppedAgain ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												:sparkles: Implement Page bundling and image handling
This commit is not the smallest in Hugo's history.
Some hightlights include:
* Page bundles (for complete articles, keeping images and content together etc.).
* Bundled images can be processed in as many versions/sizes as you need with the three methods `Resize`, `Fill` and `Fit`.
* Processed images are cached inside `resources/_gen/images` (default) in your project.
* Symbolic links (both files and dirs) are now allowed anywhere inside /content
* A new table based build summary
* The "Total in nn ms" now reports the total including the handling of the files inside /static. So if it now reports more than you're used to, it is just **more real** and probably faster than before (see below).
A site building  benchmark run compared to `v0.31.1` shows that this should be slightly faster and use less memory:
```bash
▶ ./benchSite.sh "TOML,num_langs=.*,num_root_sections=5,num_pages=(500|1000),tags_per_page=5,shortcodes,render"
benchmark                                                                                                         old ns/op     new ns/op     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      101785785     78067944      -23.30%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     185481057     149159919     -19.58%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      103149918     85679409      -16.94%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     203515478     169208775     -16.86%
benchmark                                                                                                         old allocs     new allocs     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      532464         391539         -26.47%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1056549        772702         -26.87%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      555974         406630         -26.86%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     1086545        789922         -27.30%
benchmark                                                                                                         old bytes     new bytes     delta
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      53243246      43598155      -18.12%
BenchmarkSiteBuilding/TOML,num_langs=1,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     105811617     86087116      -18.64%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=500,tags_per_page=5,shortcodes,render-4      54558852      44545097      -18.35%
BenchmarkSiteBuilding/TOML,num_langs=3,num_root_sections=5,num_pages=1000,tags_per_page=5,shortcodes,render-4     106903858     86978413      -18.64%
```
Fixes #3651
Closes #3158
Fixes #1014
Closes #2021
Fixes #1240
Updates #3757
											 
										 
										
											2017-07-24 09:00:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-21 16:50:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func   TestImageTransformFormat ( t   * testing . T )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c   :=   qt . New ( t ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 image   :=   fetchSunset ( c ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 fileCache   :=   image . ( specProvider ) . getSpec ( ) . FileCaches . ImageCache ( ) . Fs 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-21 10:59:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assertExtWidthHeight   :=   func ( img   images . ImageResource ,   ext   string ,   w ,   h   int )   { 
  
						 
					
						
							
								
									
										
										
										
											2019-09-21 16:50:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 c . Helper ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( img ,   qt . Not ( qt . IsNil ) ) 
  
						 
					
						
							
								
									
										
										
										
											2021-06-18 10:27:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 c . Assert ( paths . Ext ( img . RelPermalink ( ) ) ,   qt . Equals ,   ext ) 
  
						 
					
						
							
								
									
										
										
										
											2019-09-21 16:50:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 c . Assert ( img . Width ( ) ,   qt . Equals ,   w ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( img . Height ( ) ,   qt . Equals ,   h ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( image . RelPermalink ( ) ,   qt . Equals ,   "/a/sunset.jpg" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( image . ResourceType ( ) ,   qt . Equals ,   "image" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 assertExtWidthHeight ( image ,   ".jpg" ,   900 ,   562 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 imagePng ,   err   :=   image . Resize ( "450x png" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( imagePng . RelPermalink ( ) ,   qt . Equals ,   "/a/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_450x0_resize_linear.png" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( imagePng . ResourceType ( ) ,   qt . Equals ,   "image" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 assertExtWidthHeight ( imagePng ,   ".png" ,   450 ,   281 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( imagePng . Name ( ) ,   qt . Equals ,   "sunset.jpg" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( imagePng . MediaType ( ) . String ( ) ,   qt . Equals ,   "image/png" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 assertFileCache ( c ,   fileCache ,   path . Base ( imagePng . RelPermalink ( ) ) ,   450 ,   281 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 imageGif ,   err   :=   image . Resize ( "225x gif" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( imageGif . RelPermalink ( ) ,   qt . Equals ,   "/a/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_225x0_resize_linear.gif" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( imageGif . ResourceType ( ) ,   qt . Equals ,   "image" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 assertExtWidthHeight ( imageGif ,   ".gif" ,   225 ,   141 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( imageGif . Name ( ) ,   qt . Equals ,   "sunset.jpg" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( imageGif . MediaType ( ) . String ( ) ,   qt . Equals ,   "image/gif" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 assertFileCache ( c ,   fileCache ,   path . Base ( imageGif . RelPermalink ( ) ) ,   225 ,   141 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-03-30 09:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://github.com/gohugoio/hugo/issues/5730 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func   TestImagePermalinkPublishOrder ( t   * testing . T )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 for   _ ,   checkOriginalFirst   :=   range   [ ] bool { true ,   false }   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 name   :=   "OriginalFirst" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 if   ! checkOriginalFirst   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 name   =   "ResizedFirst" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 t . Run ( name ,   func ( t   * testing . T )   { 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 c   :=   qt . New ( t ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 spec ,   workDir   :=   newTestResourceOsFs ( c ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 defer   func ( )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 os . Remove ( workDir ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 } ( ) 
  
						 
					
						
							
								
									
										
										
										
											2019-03-30 09:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-21 10:59:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 check1   :=   func ( img   images . ImageResource )   { 
  
						 
					
						
							
								
									
										
										
										
											2019-03-30 09:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												 resizedLink   :=   "/a/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_100x50_resize_q75_box.jpg" 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												 c . Assert ( img . RelPermalink ( ) ,   qt . Equals ,   resizedLink ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 assertImageFile ( c ,   spec . PublishFs ,   resizedLink ,   100 ,   50 ) 
  
						 
					
						
							
								
									
										
										
										
											2019-03-30 09:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-21 10:59:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 check2   :=   func ( img   images . ImageResource )   { 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												 c . Assert ( img . RelPermalink ( ) ,   qt . Equals ,   "/a/sunset.jpg" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 assertImageFile ( c ,   spec . PublishFs ,   "a/sunset.jpg" ,   900 ,   562 ) 
  
						 
					
						
							
								
									
										
										
										
											2019-03-30 09:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 orignal   :=   fetchImageForSpec ( spec ,   c ,   "sunset.jpg" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( orignal ,   qt . Not ( qt . IsNil ) ) 
  
						 
					
						
							
								
									
										
										
										
											2019-03-30 09:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 if   checkOriginalFirst   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 check2 ( orignal ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 resized ,   err   :=   orignal . Resize ( "100x50" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2019-03-30 09:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-21 10:59:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 check1 ( resized . ( images . ImageResource ) ) 
  
						 
					
						
							
								
									
										
										
										
											2019-03-30 09:12:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 if   ! checkOriginalFirst   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 check2 ( orignal ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-06-15 18:22:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func   TestImageBugs ( t   * testing . T )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c   :=   qt . New ( t ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 // Issue #4261 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Run ( "Transform long filename" ,   func ( c   * qt . C )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 image   :=   fetchImage ( c ,   "1234567890qwertyuiopasdfghjklzxcvbnm5to6eeeeee7via8eleph.jpg" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( image ,   qt . Not ( qt . IsNil ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 resized ,   err   :=   image . Resize ( "200x" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( resized ,   qt . Not ( qt . IsNil ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( resized . Width ( ) ,   qt . Equals ,   200 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( resized . RelPermalink ( ) ,   qt . Equals ,   "/a/_hu59e56ffff1bc1d8d122b1403d34e039f_90587_65b757a6e14debeae720fe8831f0a9bc.jpg" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 resized ,   err   =   resized . Resize ( "100x" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( resized ,   qt . Not ( qt . IsNil ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( resized . Width ( ) ,   qt . Equals ,   100 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( resized . RelPermalink ( ) ,   qt . Equals ,   "/a/_hu59e56ffff1bc1d8d122b1403d34e039f_90587_c876768085288f41211f768147ba2647.jpg" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 // Issue #6137 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Run ( "Transform upper case extension" ,   func ( c   * qt . C )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 image   :=   fetchImage ( c ,   "sunrise.JPG" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 resized ,   err   :=   image . Resize ( "200x" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( resized ,   qt . Not ( qt . IsNil ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( resized . Width ( ) ,   qt . Equals ,   200 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 // Issue #7955 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Run ( "Fill with smartcrop" ,   func ( c   * qt . C )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 sunset   :=   fetchImage ( c ,   "sunset.jpg" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 for   _ ,   test   :=   range   [ ] struct   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 originalDimensions   string 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 targetWH             int 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 { "408x403" ,   400 } , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 { "425x403" ,   400 } , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 { "459x429" ,   400 } , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 { "476x442" ,   400 } , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 { "544x403" ,   400 } , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 { "476x468" ,   400 } , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 { "578x585" ,   550 } , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 { "578x598" ,   550 } , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 }   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Run ( test . originalDimensions ,   func ( c   * qt . C )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 image ,   err   :=   sunset . Resize ( test . originalDimensions ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 resized ,   err   :=   image . Fill ( fmt . Sprintf ( "%dx%d smart" ,   test . targetWH ,   test . targetWH ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 c . Assert ( resized ,   qt . Not ( qt . IsNil ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 c . Assert ( resized . Width ( ) ,   qt . Equals ,   test . targetWH ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 c . Assert ( resized . Height ( ) ,   qt . Equals ,   test . targetWH ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 } ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func   TestImageTransformConcurrent ( t   * testing . T )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 var   wg   sync . WaitGroup 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c   :=   qt . New ( t ) 
  
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 spec ,   workDir   :=   newTestResourceOsFs ( c ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 defer   func ( )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 os . Remove ( workDir ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ( ) 
  
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 image   :=   fetchImageForSpec ( spec ,   c ,   "sunset.jpg" ) 
  
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 for   i   :=   0 ;   i   <   4 ;   i ++   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 wg . Add ( 1 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 go   func ( id   int )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 defer   wg . Done ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 for   j   :=   0 ;   j   <   5 ;   j ++   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 img   :=   image 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 for   k   :=   0 ;   k   <   2 ;   k ++   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 r1 ,   err   :=   img . Resize ( fmt . Sprintf ( "%dx" ,   id - k ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 if   err   !=   nil   { 
  
						 
					
						
							
								
									
										
										
										
											2019-03-24 10:11:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														 t . Error ( err ) 
  
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 if   r1 . Width ( )   !=   id - k   { 
  
						 
					
						
							
								
									
										
										
										
											2019-03-24 10:11:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														 t . Errorf ( "Width: %d:%d" ,   r1 . Width ( ) ,   j ) 
  
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 r2 ,   err   :=   r1 . Resize ( fmt . Sprintf ( "%dx" ,   id - k - 1 ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 if   err   !=   nil   { 
  
						 
					
						
							
								
									
										
										
										
											2019-03-24 10:11:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														 t . Error ( err ) 
  
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													 img   =   r2 
  
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } ( i   +   20 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 wg . Wait ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-01-15 20:40:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func   TestImageWithMetadata ( t   * testing . T )   { 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c   :=   qt . New ( t ) 
  
						 
					
						
							
								
									
										
										
										
											2018-01-15 20:40:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 image   :=   fetchSunset ( c ) 
  
						 
					
						
							
								
									
										
										
										
											2018-01-15 20:40:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-17 22:03:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 meta   :=   [ ] map [ string ] any { 
  
						 
					
						
							
								
									
										
										
										
											2018-02-21 09:23:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 { 
  
						 
					
						
							
								
									
										
										
										
											2018-01-15 20:40:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 "title" :   "My Sunset" , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 "name" :    "Sunset #:counter" , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 "src" :     "*.jpg" , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( AssignMetadata ( meta ,   image ) ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( image . Name ( ) ,   qt . Equals ,   "Sunset #1" ) 
  
						 
					
						
							
								
									
										
										
										
											2018-01-15 20:40:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 resized ,   err   :=   image . Resize ( "200x" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( resized . Name ( ) ,   qt . Equals ,   "Sunset #1" ) 
  
						 
					
						
							
								
									
										
										
										
											2018-01-15 20:40:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-02-19 16:34:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func   TestImageResize8BitPNG ( t   * testing . T )   { 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c   :=   qt . New ( t ) 
  
						 
					
						
							
								
									
										
										
										
											2018-02-19 16:34:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 image   :=   fetchImage ( c ,   "gohugoio.png" ) 
  
						 
					
						
							
								
									
										
										
										
											2018-02-19 16:34:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( image . MediaType ( ) . Type ( ) ,   qt . Equals ,   "image/png" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( image . RelPermalink ( ) ,   qt . Equals ,   "/a/gohugoio.png" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( image . ResourceType ( ) ,   qt . Equals ,   "image" ) 
  
						 
					
						
							
								
									
										
										
										
											2020-09-14 17:19:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( image . Exif ( ) ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2018-02-19 16:34:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 resized ,   err   :=   image . Resize ( "800x" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( resized . MediaType ( ) . Type ( ) ,   qt . Equals ,   "image/png" ) 
  
						 
					
						
							
								
									
										
										
										
											2021-07-07 10:24:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( resized . RelPermalink ( ) ,   qt . Equals ,   "/a/gohugoio_hu0e1b9e4a4be4d6f86c7b37b9ccce3fbc_73886_800x0_resize_linear_3.png" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( resized . Width ( ) ,   qt . Equals ,   800 ) 
  
						 
					
						
							
								
									
										
										
										
											2018-02-19 16:34:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-14 09:33:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func   TestImageResizeInSubPath ( t   * testing . T )   { 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c   :=   qt . New ( t ) 
  
						 
					
						
							
								
									
										
										
										
											2018-03-14 09:33:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 image   :=   fetchImage ( c ,   "sub/gohugoio2.png" ) 
  
						 
					
						
							
								
									
										
										
										
											2018-03-14 09:33:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( image . MediaType ( ) ,   eq ,   media . PNGType ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( image . RelPermalink ( ) ,   qt . Equals ,   "/a/sub/gohugoio2.png" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( image . ResourceType ( ) ,   qt . Equals ,   "image" ) 
  
						 
					
						
							
								
									
										
										
										
											2020-09-14 17:19:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( image . Exif ( ) ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2018-03-14 09:33:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 resized ,   err   :=   image . Resize ( "101x101" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( resized . MediaType ( ) . Type ( ) ,   qt . Equals ,   "image/png" ) 
  
						 
					
						
							
								
									
										
										
										
											2021-07-07 10:24:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( resized . RelPermalink ( ) ,   qt . Equals ,   "/a/sub/gohugoio2_hu0e1b9e4a4be4d6f86c7b37b9ccce3fbc_73886_101x101_resize_linear_3.png" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( resized . Width ( ) ,   qt . Equals ,   101 ) 
  
						 
					
						
							
								
									
										
										
										
											2020-09-14 17:19:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( resized . Exif ( ) ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2018-03-14 09:33:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-21 17:21:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 publishedImageFilename   :=   filepath . Clean ( resized . RelPermalink ( ) ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 spec   :=   image . ( specProvider ) . getSpec ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 assertImageFile ( c ,   spec . BaseFs . PublishFs ,   publishedImageFilename ,   101 ,   101 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( spec . BaseFs . PublishFs . Remove ( publishedImageFilename ) ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2018-03-14 09:33:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-16 16:56:32 +05:45 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 // Clear mem cache to simulate reading from the file cache. 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 spec . imageCache . clear ( ) 
  
						 
					
						
							
								
									
										
										
										
											2018-03-14 09:33:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 resizedAgain ,   err   :=   image . Resize ( "101x101" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2021-07-07 10:24:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( resizedAgain . RelPermalink ( ) ,   qt . Equals ,   "/a/sub/gohugoio2_hu0e1b9e4a4be4d6f86c7b37b9ccce3fbc_73886_101x101_resize_linear_3.png" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( resizedAgain . Width ( ) ,   qt . Equals ,   101 ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assertImageFile ( c ,   image . ( specProvider ) . getSpec ( ) . BaseFs . PublishFs ,   publishedImageFilename ,   101 ,   101 ) 
  
						 
					
						
							
								
									
										
										
										
											2018-03-14 09:33:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-02-27 18:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func   TestSVGImage ( t   * testing . T )   { 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c   :=   qt . New ( t ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 spec   :=   newTestResourceSpec ( specDescriptor { c :   c } ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 svg   :=   fetchResourceForSpec ( spec ,   c ,   "circle.svg" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( svg ,   qt . Not ( qt . IsNil ) ) 
  
						 
					
						
							
								
									
										
										
										
											2018-02-27 18:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-04-15 17:07:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func   TestSVGImageContent ( t   * testing . T )   { 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c   :=   qt . New ( t ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-18 11:21:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 spec   :=   newTestResourceSpec ( specDescriptor { c :   c } ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 svg   :=   fetchResourceForSpec ( spec ,   c ,   "circle.svg" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( svg ,   qt . Not ( qt . IsNil ) ) 
  
						 
					
						
							
								
									
										
										
										
											2018-04-15 17:07:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-11 16:20:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 content ,   err   :=   svg . Content ( context . Background ( ) ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( content ,   hqt . IsSameType ,   "" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( content . ( string ) ,   qt . Contains ,   ` <svg height="100" width="100"> ` ) 
  
						 
					
						
							
								
									
										
										
										
											2018-04-15 17:07:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-29 10:18:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func   TestImageExif ( t   * testing . T )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c   :=   qt . New ( t ) 
  
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:27:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 fs   :=   afero . NewMemMapFs ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 spec   :=   newTestResourceSpec ( specDescriptor { fs :   fs ,   c :   c } ) 
  
						 
					
						
							
								
									
										
										
										
											2022-04-21 10:59:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 image   :=   fetchResourceForSpec ( spec ,   c ,   "sunset.jpg" ) . ( images . ImageResource ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-29 10:18:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-21 10:59:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 getAndCheckExif   :=   func ( c   * qt . C ,   image   images . ImageResource )   { 
  
						 
					
						
							
								
									
										
										
										
											2020-09-14 17:19:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 x   :=   image . Exif ( ) 
  
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:27:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 c . Assert ( x ,   qt . Not ( qt . IsNil ) ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-29 10:18:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:27:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 c . Assert ( x . Date . Format ( "2006-01-02" ) ,   qt . Equals ,   "2017-10-27" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-29 10:18:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:27:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 // Malaga: https://goo.gl/taazZy 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( x . Lat ,   qt . Equals ,   float64 ( 36.59744166666667 ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( x . Long ,   qt . Equals ,   float64 ( - 4.50846 ) ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-29 10:18:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:27:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 v ,   found   :=   x . Tags [ "LensModel" ] 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( found ,   qt . Equals ,   true ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 lensModel ,   ok   :=   v . ( string ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( ok ,   qt . Equals ,   true ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( lensModel ,   qt . Equals ,   "smc PENTAX-DA* 16-50mm F2.8 ED AL [IF] SDM" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 resized ,   _   :=   image . Resize ( "300x200" ) 
  
						 
					
						
							
								
									
										
										
										
											2020-09-14 17:19:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 x2   :=   resized . Exif ( ) 
  
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:27:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 c . Assert ( x2 ,   eq ,   x ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
									
										
										
										
											2019-08-29 10:18:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:27:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 getAndCheckExif ( c ,   image ) 
  
						 
					
						
							
								
									
										
										
										
											2022-04-21 10:59:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 image   =   fetchResourceForSpec ( spec ,   c ,   "sunset.jpg" ) . ( images . ImageResource ) 
  
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:27:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 // This will read from file cache. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 getAndCheckExif ( c ,   image ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-29 10:18:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:57:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func   BenchmarkImageExif ( b   * testing . B )   { 
  
						 
					
						
							
								
									
										
										
										
											2022-04-21 10:59:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 getImages   :=   func ( c   * qt . C ,   b   * testing . B ,   fs   afero . Fs )   [ ] images . ImageResource   { 
  
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:57:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 spec   :=   newTestResourceSpec ( specDescriptor { fs :   fs ,   c :   c } ) 
  
						 
					
						
							
								
									
										
										
										
											2022-04-21 10:59:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 imgs   :=   make ( [ ] images . ImageResource ,   b . N ) 
  
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:57:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 for   i   :=   0 ;   i   <   b . N ;   i ++   { 
  
						 
					
						
							
								
									
										
										
										
											2022-04-21 10:59:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 imgs [ i ]   =   fetchResourceForSpec ( spec ,   c ,   "sunset.jpg" ,   strconv . Itoa ( i ) ) . ( images . ImageResource ) 
  
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:57:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
									
										
										
										
											2022-04-21 10:59:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 return   imgs 
  
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:57:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-21 10:59:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 getAndCheckExif   :=   func ( c   * qt . C ,   image   images . ImageResource )   { 
  
						 
					
						
							
								
									
										
										
										
											2020-09-14 17:19:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 x   :=   image . Exif ( ) 
  
						 
					
						
							
								
									
										
										
										
											2019-09-01 17:57:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 c . Assert ( x ,   qt . Not ( qt . IsNil ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( x . Long ,   qt . Equals ,   float64 ( - 4.50846 ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 b . Run ( "Cold cache" ,   func ( b   * testing . B )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 b . StopTimer ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c   :=   qt . New ( b ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 images   :=   getImages ( c ,   b ,   afero . NewMemMapFs ( ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 b . StartTimer ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 for   i   :=   0 ;   i   <   b . N ;   i ++   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 getAndCheckExif ( c ,   images [ i ] ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 b . Run ( "Cold cache, 10" ,   func ( b   * testing . B )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 b . StopTimer ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c   :=   qt . New ( b ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 images   :=   getImages ( c ,   b ,   afero . NewMemMapFs ( ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 b . StartTimer ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 for   i   :=   0 ;   i   <   b . N ;   i ++   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 for   j   :=   0 ;   j   <   10 ;   j ++   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 getAndCheckExif ( c ,   images [ i ] ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 b . Run ( "Warm cache" ,   func ( b   * testing . B )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 b . StopTimer ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c   :=   qt . New ( b ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 fs   :=   afero . NewMemMapFs ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 images   :=   getImages ( c ,   b ,   fs ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 for   i   :=   0 ;   i   <   b . N ;   i ++   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 getAndCheckExif ( c ,   images [ i ] ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 images   =   getImages ( c ,   b ,   fs ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 b . StartTimer ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 for   i   :=   0 ;   i   <   b . N ;   i ++   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 getAndCheckExif ( c ,   images [ i ] ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-07 12:35:00 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// usesFMA indicates whether "fused multiply and add" (FMA) instruction is 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// used.  The command "grep FMADD go/test/codegen/floats.go" can help keep 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// the FMA-using architecture list updated. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var   usesFMA   =   runtime . GOARCH   ==   "s390x"   || 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 runtime . GOARCH   ==   "ppc64"   || 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 runtime . GOARCH   ==   "ppc64le"   || 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 runtime . GOARCH   ==   "arm64" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// goldenEqual compares two NRGBA images.  It is used in golden tests only. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// A small tolerance is allowed on architectures using "fused multiply and add" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// (FMA) instruction to accommodate for floating-point rounding differences 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// with control golden images that were generated on amd64 architecture. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// See https://golang.org/ref/spec#Floating_point_operators 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// and https://github.com/gohugoio/hugo/issues/6387 for more information. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								//
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Borrowed from https://github.com/disintegration/gift/blob/a999ff8d5226e5ab14b64a94fca07c4ac3f357cf/gift_test.go#L598-L625 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Copyright (c) 2014-2019 Grigory Dryapak 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Licensed under the MIT License. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func   goldenEqual ( img1 ,   img2   * image . NRGBA )   bool   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 maxDiff   :=   0 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 if   usesFMA   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 maxDiff   =   1 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 if   ! img1 . Rect . Eq ( img2 . Rect )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 return   false 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 if   len ( img1 . Pix )   !=   len ( img2 . Pix )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 return   false 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 for   i   :=   0 ;   i   <   len ( img1 . Pix ) ;   i ++   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 diff   :=   int ( img1 . Pix [ i ] )   -   int ( img2 . Pix [ i ] ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 if   diff   <   0   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 diff   =   - diff 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 if   diff   >   maxDiff   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 return   false 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 return   true 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 09:34:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Issue #8729 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func   TestImageOperationsGoldenWebp ( t   * testing . T )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 if   ! webp . Supports ( )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 t . Skip ( "skip webp test" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c   :=   qt . New ( t ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Parallel ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 devMode   :=   false 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 testImages   :=   [ ] string { "fuzzy-cirlcle.png" } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 spec ,   workDir   :=   newTestResourceOsFs ( c ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 defer   func ( )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 if   ! devMode   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 os . Remove ( workDir ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 if   devMode   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 fmt . Println ( workDir ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 for   _ ,   imageName   :=   range   testImages   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 image   :=   fetchImageForSpec ( spec ,   c ,   imageName ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 imageWebp ,   err   :=   image . Resize ( "200x webp" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( imageWebp . Width ( ) ,   qt . Equals ,   200 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 if   devMode   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 return 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 dir1   :=   filepath . Join ( workDir ,   "resources/_gen/images" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 dir2   :=   filepath . FromSlash ( "testdata/golden_webp" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 assetGoldenDirs ( c ,   dir1 ,   dir2 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func   TestImageOperationsGolden ( t   * testing . T )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c   :=   qt . New ( t ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Parallel ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-07 12:49:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 // Note, if you're enabling this on a MacOS M1 (ARM) you need to run the test with GOARCH=amd64. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 // GOARCH=amd64 go test -timeout 30s -run "^TestImageOperationsGolden$" ./resources -v 
  
						 
					
						
							
								
									
										
										
										
											2022-10-04 11:00:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 // The above will print out a folder. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 // Replace testdata/golden with resources/_gen/images in that folder. 
  
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 devMode   :=   false 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 testImages   :=   [ ] string { "sunset.jpg" ,   "gohugoio8.png" ,   "gohugoio24.png" } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 spec ,   workDir   :=   newTestResourceOsFs ( c ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 defer   func ( )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 if   ! devMode   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 os . Remove ( workDir ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 if   devMode   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 fmt . Println ( workDir ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-12-16 13:52:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 gopher   :=   fetchImageForSpec ( spec ,   c ,   "gopher-hero8.png" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 var   err   error 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 gopher ,   err   =   gopher . Resize ( "30x" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-20 10:39:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 // Test PNGs with alpha channel. 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 for   _ ,   img   :=   range   [ ] string { "gopher-hero8.png" ,   "gradient-circle.png" }   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 orig   :=   fetchImageForSpec ( spec ,   c ,   img ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 for   _ ,   resizeSpec   :=   range   [ ] string { "200x #e3e615" ,   "200x jpg #e3e615" }   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 resized ,   err   :=   orig . Resize ( resizeSpec ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 rel   :=   resized . RelPermalink ( ) 
  
						 
					
						
							
								
									
										
										
										
											2022-06-11 18:52:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-20 10:39:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 c . Assert ( rel ,   qt . Not ( qt . Equals ) ,   "" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-12 15:14:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 // A simple Gif file (no animation). 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 orig   :=   fetchImageForSpec ( spec ,   c ,   "gohugoio-card.gif" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 for   _ ,   resizeSpec   :=   range   [ ] string { "100x" ,   "220x" }   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 resized ,   err   :=   orig . Resize ( resizeSpec ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 rel   :=   resized . RelPermalink ( ) 
  
						 
					
						
							
								
									
										
										
										
											2022-06-11 18:52:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 c . Assert ( rel ,   qt . Not ( qt . Equals ) ,   "" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 // Animated GIF 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 orig   =   fetchImageForSpec ( spec ,   c ,   "giphy.gif" ) 
  
						 
					
						
							
								
									
										
										
										
											2022-10-04 11:00:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 for   _ ,   resizeSpec   :=   range   [ ] string { "200x" ,   "512x" ,   "100x jpg" }   { 
  
						 
					
						
							
								
									
										
										
										
											2022-06-11 18:52:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 resized ,   err   :=   orig . Resize ( resizeSpec ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 rel   :=   resized . RelPermalink ( ) 
  
						 
					
						
							
								
									
										
										
										
											2022-06-12 15:14:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 c . Assert ( rel ,   qt . Not ( qt . Equals ) ,   "" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 for   _ ,   img   :=   range   testImages   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 orig   :=   fetchImageForSpec ( spec ,   c ,   img ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 for   _ ,   resizeSpec   :=   range   [ ] string { "200x100" ,   "600x" ,   "200x r90 q50 Box" }   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 resized ,   err   :=   orig . Resize ( resizeSpec ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 rel   :=   resized . RelPermalink ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( rel ,   qt . Not ( qt . Equals ) ,   "" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 for   _ ,   fillSpec   :=   range   [ ] string { "300x200 Gaussian Smart" ,   "100x100 Center" ,   "300x100 TopLeft NearestNeighbor" ,   "400x200 BottomLeft" }   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 resized ,   err   :=   orig . Fill ( fillSpec ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 rel   :=   resized . RelPermalink ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( rel ,   qt . Not ( qt . Equals ) ,   "" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 for   _ ,   fitSpec   :=   range   [ ] string { "300x200 Linear" }   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 resized ,   err   :=   orig . Fit ( fitSpec ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 rel   :=   resized . RelPermalink ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( rel ,   qt . Not ( qt . Equals ) ,   "" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 f   :=   & images . Filters { } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 filters   :=   [ ] gift . Filter { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . Grayscale ( ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . GaussianBlur ( 6 ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . Saturation ( 50 ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . Sepia ( 100 ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . Brightness ( 30 ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . ColorBalance ( 10 ,   - 10 ,   - 10 ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . Colorize ( 240 ,   50 ,   100 ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . Gamma ( 1.5 ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . UnsharpMask ( 1 ,   1 ,   0 ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . Sigmoid ( 0.5 ,   7 ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . Pixelate ( 5 ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . Invert ( ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . Hue ( 22 ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . Contrast ( 32.5 ) , 
  
						 
					
						
							
								
									
										
										
										
											2020-12-16 13:52:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 f . Overlay ( gopher . ( images . ImageSource ) ,   20 ,   30 ) , 
  
						 
					
						
							
								
									
										
										
										
											2021-12-07 11:29:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 f . Text ( "No options" ) , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 f . Text ( "This long text is to test line breaks. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." ) , 
  
						 
					
						
							
								
									
										
										
										
											2022-03-17 22:03:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 f . Text ( "Hugo rocks!" ,   map [ string ] any { "x" :   3 ,   "y" :   3 ,   "size" :   20 ,   "color" :   "#fc03b1" } ) , 
  
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 resized ,   err   :=   orig . Fill ( "400x200 center" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-09-10 11:26:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 for   _ ,   filter   :=   range   filters   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 resized ,   err   :=   resized . Filter ( filter ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 rel   :=   resized . RelPermalink ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( rel ,   qt . Not ( qt . Equals ) ,   "" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-04 14:07:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 resized ,   err   =   resized . Filter ( filters [ 0 : 4 ] ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 rel   :=   resized . RelPermalink ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( rel ,   qt . Not ( qt . Equals ) ,   "" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 if   devMode   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 return 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-09-03 10:36:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 dir1   :=   filepath . Join ( workDir ,   "resources/_gen/images" ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 dir2   :=   filepath . FromSlash ( "testdata/golden" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-07 09:34:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 assetGoldenDirs ( c ,   dir1 ,   dir2 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func   assetGoldenDirs ( c   * qt . C ,   dir1 ,   dir2   string )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 // The two dirs above should now be the same. 
  
						 
					
						
							
								
									
										
										
										
											2023-02-19 00:43:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 dirinfos1 ,   err   :=   os . ReadDir ( dir1 ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
									
										
										
										
											2023-02-19 00:43:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 dirinfos2 ,   err   :=   os . ReadDir ( dir2 ) 
  
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 c . Assert ( len ( dirinfos1 ) ,   qt . Equals ,   len ( dirinfos2 ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 for   i ,   fi1   :=   range   dirinfos1   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 fi2   :=   dirinfos2 [ i ] 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( fi1 . Name ( ) ,   qt . Equals ,   fi2 . Name ( ) ) 
  
						 
					
						
							
								
									
										
										
										
											2019-10-07 12:35:00 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 f1 ,   err   :=   os . Open ( filepath . Join ( dir1 ,   fi1 . Name ( ) ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 f2 ,   err   :=   os . Open ( filepath . Join ( dir2 ,   fi2 . Name ( ) ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-11 18:52:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 decodeAll   :=   func ( f   * os . File )   [ ] image . Image   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 var   images   [ ] image . Image 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 if   strings . HasSuffix ( f . Name ( ) ,   ".gif" )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 gif ,   err   :=   gif . DecodeAll ( f ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 images   =   make ( [ ] image . Image ,   len ( gif . Image ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 for   i ,   img   :=   range   gif . Image   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 images [ i ]   =   img 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 }   else   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 img ,   _ ,   err   :=   image . Decode ( f ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 images   =   append ( images ,   img ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 return   images 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-11 18:52:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 imgs1   :=   decodeAll ( f1 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 imgs2   :=   decodeAll ( f2 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 c . Assert ( len ( imgs1 ) ,   qt . Equals ,   len ( imgs2 ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 LOOP : 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 for   i ,   img1   :=   range   imgs1   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 img2   :=   imgs2 [ i ] 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 nrgba1   :=   image . NewNRGBA ( img1 . Bounds ( ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 gift . New ( ) . Draw ( nrgba1 ,   img1 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 nrgba2   :=   image . NewNRGBA ( img2 . Bounds ( ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 gift . New ( ) . Draw ( nrgba2 ,   img2 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 if   ! goldenEqual ( nrgba1 ,   nrgba2 )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 switch   fi1 . Name ( )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 case   "gohugoio8_hu7f72c00afdf7634587afaa5eff2a25b2_73538_73c19c5f80881858a85aa23cd0ca400d.png" , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 "gohugoio8_hu7f72c00afdf7634587afaa5eff2a25b2_73538_ae631e5252bb5d7b92bc766ad1a89069.png" , 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 "gohugoio8_hu7f72c00afdf7634587afaa5eff2a25b2_73538_d1bbfa2629bffb90118cacce3fcfb924.png" , 
  
						 
					
						
							
								
									
										
										
										
											2022-10-04 16:19:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													 "giphy_hu3eafc418e52414ace6236bf1d31f82e1_52213_200x0_resize_box_1.gif" : 
  
						 
					
						
							
								
									
										
										
										
											2022-06-11 18:52:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													 c . Log ( "expectedly differs from golden due to dithering:" ,   fi1 . Name ( ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 default : 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 c . Errorf ( "resulting image differs from golden: %s" ,   fi1 . Name ( ) ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													 break   LOOP 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 } 
  
						 
					
						
							
								
									
										
										
										
											2019-10-07 12:35:00 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 if   ! usesFMA   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( fi1 ,   eq ,   fi2 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 _ ,   err   =   f1 . Seek ( 0 ,   0 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 _ ,   err   =   f2 . Seek ( 0 ,   0 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 hash1 ,   err   :=   helpers . MD5FromReader ( f1 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 hash2 ,   err   :=   helpers . MD5FromReader ( f2 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( err ,   qt . IsNil ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 c . Assert ( hash1 ,   qt . Equals ,   hash2 ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-08-26 19:12:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										 f1 . Close ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 f2 . Close ( ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func   BenchmarkResizeParallel ( b   * testing . B )   { 
  
						 
					
						
							
								
									
										
										
										
											2019-08-10 21:05:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									 c   :=   qt . New ( b ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 img   :=   fetchSunset ( c ) 
  
						 
					
						
							
								
									
										
										
										
											2018-02-13 21:45:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 b . RunParallel ( func ( pb   * testing . PB )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 for   pb . Next ( )   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 w   :=   rand . Intn ( 10 )   +   10 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 resized ,   err   :=   img . Resize ( strconv . Itoa ( w )   +   "x" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 if   err   !=   nil   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 b . Fatal ( err ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 _ ,   err   =   resized . Resize ( strconv . Itoa ( w - 1 )   +   "x" ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 if   err   !=   nil   { 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												 b . Fatal ( err ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										 } 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									 } ) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}