mirror of
				https://github.com/Kakune55/ComiPy.git
				synced 2025-11-04 06:24:40 +08:00 
			
		
		
		
	fix:修复了缩放过程中图片比例错误的问题
This commit is contained in:
		
							
								
								
									
										6
									
								
								file.py
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								file.py
									
									
									
									
									
								
							@@ -71,10 +71,10 @@ def thumbnail(input, minSize: int = 600):
 | 
				
			|||||||
    img = cv2.imdecode(np.frombuffer(input, np.uint8), cv2.IMREAD_COLOR)
 | 
					    img = cv2.imdecode(np.frombuffer(input, np.uint8), cv2.IMREAD_COLOR)
 | 
				
			||||||
    height = img.shape[0]  # 图片高度
 | 
					    height = img.shape[0]  # 图片高度
 | 
				
			||||||
    width = img.shape[1]  # 图片宽度
 | 
					    width = img.shape[1]  # 图片宽度
 | 
				
			||||||
    if height < width:
 | 
					    if height > width:
 | 
				
			||||||
        newshape = (int(minSize / width * height), minSize)
 | 
					 | 
				
			||||||
    else:
 | 
					 | 
				
			||||||
        newshape = (minSize, int(minSize / width * height))
 | 
					        newshape = (minSize, int(minSize / width * height))
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
 | 
					        newshape = (int(minSize / height * width), minSize)
 | 
				
			||||||
    img = cv2.resize(img, newshape)
 | 
					    img = cv2.resize(img, newshape)
 | 
				
			||||||
    success, encoded_image = cv2.imencode(".webp", img, [cv2.IMWRITE_WEBP_QUALITY, 75])
 | 
					    success, encoded_image = cv2.imencode(".webp", img, [cv2.IMWRITE_WEBP_QUALITY, 75])
 | 
				
			||||||
    return encoded_image.tobytes()
 | 
					    return encoded_image.tobytes()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,4 @@
 | 
				
			|||||||
shortuuid
 | 
					shortuuid
 | 
				
			||||||
flask
 | 
					flask
 | 
				
			||||||
opencv-python
 | 
					opencv-python
 | 
				
			||||||
 | 
					opencv-python-headless
 | 
				
			||||||
@@ -28,7 +28,7 @@
 | 
				
			|||||||
        img {
 | 
					        img {
 | 
				
			||||||
            display: block;
 | 
					            display: block;
 | 
				
			||||||
            width: 100%;
 | 
					            width: 100%;
 | 
				
			||||||
            min-height: 300px;
 | 
					            min-height: 200px;
 | 
				
			||||||
            margin-top: 10px;
 | 
					            margin-top: 10px;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user