无法将图片另存为.png

时间:2019-02-23 23:27:25

标签: python png python-imaging-library

我正在研究我去年编写的程序。当时工作正常,但现在运行它时出现错误。我是Python的初学者,不确定如何解决此问题。本质上,当我尝试另存为.png时出现以下错误。

import PIL
from PIL import Image

# Use PIL to import image
img = Image.open("jenny.jpg")
newImg=img.save("jenny.png")

ValueError:未知文件扩展名:.png

1 个答案:

答案 0 :(得分:0)

您需要安装public class MainActivity extends AppCompatActivity { Button mButtonGive; TextView mTextPromo; FirebaseFirestore mRef = FirebaseFirestore.getInstance(); CollectionReference mDelRef = mRef.collection("Promocode").document("Delivery").collection("Promocode"); CollectionReference mIviRef = mRef.collection("Promocode").document("Ivi").collection("Promocode"); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mButtonGive = findViewById(R.id.mButtonGive); mTextPromo = findViewById(R.id.mTextPromo); mButtonGive.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mDelRef.get() .addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() { @Override public void onSuccess(QuerySnapshot queryDocumentSnapshots) { List<DocumentSnapshot> list = queryDocumentSnapshots.getDocuments(); String text = list.toString(); mTextPromo.setText(text); } }); } }); } } 而不是Pillow

PIL