You don't say if you use iCloud to synchronize your iMac and your iPhone. If you are, and if you have "Download Originals" checked in Photos>Settings>iCloud, then it's pretty simple. (If you have "Optimize Storage" checked instead of "Download," then it's more complicated. Then you need to switch to Plan B!)
Plan A: So if "Download" is checked, then all of your full sized images from your phone and iCloud are on your iMac. So just find your Photos Library, located in the Pictures folder on your Mac, and copy it (drag and drop will work) to an external hard drive. Then, on your Mac Photos, delete any pictures you don't want to remain on your phone. The deletions will be replicated in iCloud and on your phone. But all the pictures will still be on the copy of the Library on the external drive.
If the external drive is formatted in either APFS format or Mac OS Extended (Journaled) format (NOT ExFat like a thumb drive), then you can double click on that Library and it will open in Photos, and you can look at the old pictures. Then go back by double clicking the one in the Pictures folder. As long as the Library in the Pictures folder is listed as your System Drive and iCloud is turned on, then your iMac Library and iCloud and your phone will remain in sync.
You can store a Library on a thumb drive or an ExFat drive, but you should never try to use it with Photos-- Photos using a Library that's on a non-mac formatted drive may permanently corrupt the Library. See this:
Move your Photos library to save space on your Mac - Apple Support
Plan B:this is if you have checked "Optimize Storage" on your Mac's Photos iCloud settings. That means that the Mac may not have copied full sized images from iCloud. It doesn't really have all your pictures. So using it as a backup doesn't work. The best thing to do in this case is, hold on, make a new empty Library.
To make a new Library for the Mac, close Photos, option click the Photos icon, and choose Create New from the Library dialog.

A new, empty Library will open. Then, on the Mac in Photos>Settings>General, you must make this new, empty Library your System Library. 
Here, "Use as System Library" is grayed out, because it already is. Then check "Download Originals," and connect it to iCloud.
Then wait. Wait some more, and eventually this new Library will fill with full sized images from iCloud. Now you can throw away the old original Library--it doesn't have full sized images, anyway. And now you have a lIbrary that has all your pictures It's just like at the beginning of Plan A. Depending on the size of your Library, you may have to wait a week or more, but the Library should tell you when it's finished syncing. It might say something like this

at the bottom of the Library view. Leave the MacBook plugged in and running as much as possible--overnight is good. Keep Photos in the background when you're not using it--Photos will slow downloads to keep from interrupting your work.
Now--you're ready to go to Plan A.
Let us know what you do and how it goes!