[#440] try to use the original image format when creating thumbs
This commit is contained in:
		
							parent
							
								
									030dfc2690
								
							
						
					
					
						commit
						2fa5233fa6
					
				| 
						 | 
					@ -305,8 +305,15 @@ func (s *System) CreateThumb(originalKey string, thumbKey, thumbSize string) err
 | 
				
			||||||
		return writerErr
 | 
							return writerErr
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// try to detect the thumb format based on the original file name
 | 
				
			||||||
 | 
						// (fallbacks to png on error)
 | 
				
			||||||
 | 
						format, err := imaging.FormatFromFilename(thumbKey)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							format = imaging.PNG
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// thumb encode (aka. upload)
 | 
						// thumb encode (aka. upload)
 | 
				
			||||||
	if err := imaging.Encode(w, thumbImg, imaging.PNG); err != nil {
 | 
						if err := imaging.Encode(w, thumbImg, format); err != nil {
 | 
				
			||||||
		w.Close()
 | 
							w.Close()
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue