This simple script retrieving a value of raster pixel size works in Python console, but can't be processed in Script editor: "No script found. Seems there is no valid script in the file." How could it be solved?
from qgis.core import QgsRasterLayer
ras = QgsRasterLayer(r"C:\Users\123\123.tif")
pixelsizeX = ras.rasterUnitsPerPixelX()
pixelsizeY = ras.rasterUnitsPerPixelY()
print (pixelsizeX)
print (pixelsizeY)