A deformed image is most likely a CSS issue and not directly related to the device being used. By “deformed” do you mean poor resolution or blurry? I took “deformed” to mean the image’s aspect ratio is incorrect. But a blurry image is because the source image is not large enough for the size of its container. You either need a larger image or a smaller container when width is > 300px.
You cannot prevent a non-mobile device from requesting the page. You can make it difficult by only offering the link to mobile devices. If the link shows up in search results, you can be sure some non-mobile users will use the link. How would you like to handle non-mobile requests for this page? You can either display alternative content, redirect elsewhere, or do nothing.
You can use the wp_is_mobile() function to see if the requesting device is mobile or not. This has nothing to do with screen size though, mobile status is based on the user agent string containing certain keywords like “Mobile” or “Android”. An iPad with a Retina display is still seen as a mobile device even though the screen’s pixel size is larger than many laptops.
PHP cannot directly detect a device’s screen size. PHP also cannot redirect once output has started. Determining screen size and redirects generally need to be managed client side with JavaScript.