Image resize under PhotoImage

后端 未结 4 801
盖世英雄少女心
盖世英雄少女心 2020-11-29 08:07

I need to resize an image, but I want to avoid PIL, since I cannot make it work under OS X - don\'t ask me why...

Anyway since I am satisfied with gif/pgm/ppm, the P

4条回答
  •  天涯浪人
    2020-11-29 08:52

    You have to either use the subsample() or the zoom() methods of the PhotoImage class. For the first option you first have to calculate the scale factors, simply explained in the following lines:

    scale_w = new_width/old_width
    scale_h = new_height/old_height
    photoImg.zoom(scale_w, scale_h)
    

提交回复
热议问题