Yii禁用http缓存(Yii disable http cache)
如何在Yii上禁用http缓存? 在我手动刷新浏览器之前,浏览器无法更新视图。
有没有像cakephp disableCache()?
How can I disable the http cache on Yii? The browser can't update the view, until I refresh the browser manually.
Is there some like cakephp disableCache()?
原文:https://stackoverflow.com/questions/21573034
更新时间:2022-06-13 19:06
最满意答案
在这里对代码进行一点改动可以使它工作:)
from PIL import Image im = Image.open('bird.jpg') width, height = im.size pixels = im.load() for y in range(int(height*.55), int(height*.75)): for x in range(width): alpha = pixels[x, y][3]-int((y - height*.55)/height/.20 * 255) if alpha <= 0: alpha = 0 pixels[x, y] = pixels[x, y][:3] + (alpha,) for y in range(y, height): for x in range(width): pixels[x, y] = pixels[x, y][:3] + (0,) bg.save('birdfade.png')
A little change on code here can make it works :)
from PIL import Image im = Image.open('bird.jpg') width, height = im.size pixels = im.load() for y in range(int(height*.55), int(height*.75)): for x in range(width): alpha = pixels[x, y][3]-int((y - height*.55)/height/.20 * 255) if alpha <= 0: alpha = 0 pixels[x, y] = pixels[x, y][:3] + (alpha,) for y in range(y, height): for x in range(width): pixels[x, y] = pixels[x, y][:3] + (0,) bg.save('birdfade.png')
相关问答
更多-
你可以看一看stsci库,它是用来比较和分析图像的。 它应该给你你想要的,但可能有点矫枉过正。 如果你想保持简单,你可以先减少颜色的数量和分辨率,然后计算距离。 You can take a look at the stsci library, it is made for comparing and analysing images. It should give you what you want but might be a little overkill. If ou want to keep it ...
-
谷歌搜索了一下,发现了一个名为cv2的软件包。 安装该软件包时遇到了困难,但我试图做的事情是可能的 import cv2 from PIL import Image img1=cv2.imread('m1.jpg') img2=cv2.imread('logo.jpg') dst=cv2.addWeighted(img1,0.7,img2,0.3,0) cv2.imshow('dst',dst) cv2.waitKey(0) cv2.destroyAllWindows() Well Googled a ...
-
在这里对代码进行一点改动可以使它工作:) from PIL import Image im = Image.open('bird.jpg') width, height = im.size pixels = im.load() for y in range(int(height*.55), int(height*.75)): for x in range(width): alpha = pixels[x, y][3]-int((y - height*.55)/height/.20 ...
-
python PIL - 背景显示不透明而不透明(python PIL - background displayed opaque instead of transparent)[2022-03-10]
这是因为JPEG无法保存包含在RGBA图像中的透明度信息。 您可能希望将头像保存为像PNG这样的格式,可以保留这些信息。 That is because JPEG cannot save transparency informations which are contained in a RGBA image. You may want to save the avatar to a format like PNG which is able to keep these informations. -
您只需要在粘贴功能中将图像指定为蒙版即可: import os from PIL import Image, ImageDraw, ImageFont filename='pikachu.png' ironman = Image.open(filename, 'r') filename1='bg.png' bg = Image.open(filename1, 'r') text_img = Image.new('RGBA', (600,320), (0, 0, 0, 0)) text_img.paste( ...
-
Python(PIL):减轻透明图像并粘贴到另一个图像(Python (PIL): Lighten transparent image and paste to another one)[2022-03-21]
根据我自己的理解,dissolve选项仅修改alpha通道。 因此,如果您希望Alpha通道仅保留其值的40%,则在PIL中执行相同的操作: from PIL import Image overlay = Image.open('overlay.png') base = Image.open('base.png') bands = list(overlay.split()) if len(bands) == 4: # Assuming alpha is the last band ban ... -
Image Gurus:优化我的Python PNG透明度功能(Image Gurus: Optimize my Python PNG transparency function)[2021-09-23]
这仍然访问每个像素,但可能会更快: new_pixels = [] for row in pixels: new_row = array('B', row) i = 0 while i < len(new_row): r = new_row[i] g = new_row[i + 1] b = new_row[i + 2] if r>threshold and g>threshold and b>threshold: ... -
看起来PIL目前不支持PNG8的完整alpha。 这里有一个补丁,只读支持: http : //mail.python.org/pipermail/image-sig/2010-October/006533.html 如果你觉得顽皮,你可以monkeypatch PIL: from PIL import Image, ImageFile, PngImagePlugin def patched_chunk_tRNS(self, pos, len): i16 = PngImagePlugin.i16 ...
-
您将图像文件保存为JPEG 。 JPEG不支持透明度。 为了使图像具有透明度,必须将其另存为支持图像透明度的格式,例如PNG 。 You are saving the image file as a JPEG. JPEGs do not support transparency. In order for your image to have transparency, you must save as a format that supports transparency in the image, su ...
-
您遇到的问题是您的图像包含透明的白色像素,而您的代码只会裁剪透明和黑色的像素。 示例图像中大多数像素的RGBA值为(255, 255, 255, 0) 。 在autocrop_image2 ,您将获取通道值的max 。 你可能只想直接获得alpha通道的值,所以改变: image_data_bw = image_data.max(axis=2) 至: image_data_bw = image_data[:,:,3] 然后该功能的其余部分应按预期工作。 autocrop_image函数具有相同的问题。 ...