How to apply a patch in the correct directory
- examine the patch to see the directory it expects to be in for applying the patch
- use the -d option to make this the starting directory (the -p option can strip from the front of the path if necessary)
patch -u -p0 -d image/contrib/image_gallery/ <image_gallery_sorting_6x.module_0.patch