How to change dimensions a mesh in blender python

I am trying to change the dimensions of a mesh (not the scale) based on the size of the pixels in an image.

I share with you the script that I have done so far, the script does change the dimensions of the mesh, but the scale still changes and that is what I do not want.

#Cargar HeightMap, aplicar modificador de dezplazamiento.
tex = bpy.data.textures.new(name=“HeightMap”, type=“IMAGE”)
tex.image = bpy.data.images.load(cfg[‘heightmap’])
hmWidth = tex.image.size[0]
hmHeight = tex.image.size[1]

— --- — --- — --- — ---#

#Crear Grid
def create_mesh():
#Añadir Mesh de Tipo Grid
bpy.ops.mesh.primitive_grid_add(x_subdivisions = 512 , y_subdivisions = 512, size = 1.0)
bpy.ops.transform.resize(value=(hmWidth,hmHeight,0))
grid = bpy.context.active_object
grid.name = ‘MapGrid’
#print(hmHeight)
tex.extension = ‘EXTEND’
mod = grid.modifiers.new("", ‘DISPLACE’)
mod.strength = 0.080
mod.mid_level = 0
mod.texture = tex
#return grid
create_mesh()

Could someone help me correct this?