Extension of the above-mentioned answer. I wrote a UNIX command so I can easily do it in my workflow.
Copy Google Drive Image URL
https://drive.google.com/file/d/XXXX/view?usp=sharing
Command:
echo https://drive.google.com/uc\?export\=view\&id\=`echo $(pbpaste) | cut -d '/' -f 6`
Output:
https://drive.google.com/uc?export=view&id=XXXX
P.S. If you copy the command from here. Make sure to copy the Google Drive image URL again. :P
No need to change anything in the Step 2 command as it takes from Clipboard. Make sure it is copied in right format E.g.
https://drive.google.com/file/d/XXXX/view?usp=sharing