简体   繁体   English

如何使用python或django查找最后修改的png文件

[英]How to find the last modified png file using python or django

I want to find which file is last modified. 我想查找最后修改的文件。

I am modifying or updating the 'png' image on each request. 我正在根据每个请求修改或更新“ png”图像。

For example: piechart.png is an image; 例如:piechart.png是图像; I am modifying this same image to create a new image (having same image name 'piechart.png'). 我正在修改同一图像以创建新图像(具有相同的图像名称“ piechart.png”)。 I will be saving & modifying 5 images: (piechart1.png,piechart2.png,... ,piechart5.png). 我将保存并修改5张图像:(piechart1.png,piechart2.png,...,piechart5.png)。

How can I find which image was modified last ? 如何找到上次修改的图像

Well, this doesn't really answer your question, but it come close. 好吧,这并不能真正回答您的问题,但是很接近。

What you can do, is first download the PIL module, or the Python Imaging Library. 您可以做的是,首先下载PIL模块或Python Imaging Library。

After that, get it installed, and then do the following: 之后,安装它,然后执行以下操作:

from PIL import Image

Jpeg = Image.open("Yourfile.jpg")

print(Jpeg.info, Jpeg.format, Jpeg.mode, Jpeg.size)

This gives you some of the properties of the photo. 这为您提供了照片的某些属性。

The same thing you can do for PNG images. 您可以对PNG图像执行相同的操作。

For more information about using the PIL module and getting your desired results you can go here: 有关使用PIL模块并获得所需结果的更多信息,请转到此处:

http://python.developpez.com/cours/pilhandbook/php/image.php http://python.developpez.com/cours/pilhandbook/php/image.php

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM