Let me explain in more detail as you’re probably referring to how iOS or Android works.
NOTE: your PIN code or passphrase is your decryption key. Your phone is encrypted when locked.
When you delete a photo LOCALLY on an encrypted iPhone or Android, (File-Based Encryption (FBE) the device does not immediately scrub the actual data from the storage chip. Instead, it performs two main actions:
First, it removes the file's entry from the file system. This marks the space as ‘available’ telling the phone it can write new data over that spot whenever it needs to.
Second, it deletes the unique encryption key associated with that specific file.
The encrypted data remains on the physical storage chip until the system eventually overwrites those blocks with new information or performs a background cleanup process called TRIM.
However, because the encryption key was destroyed, that remaining data is just a scrambled string of characters. Without the key, the data cannot be decrypted, making it mathematically impossible to recover, even if the physical bits are still there.
Encryption itself protects the data from recovery.
Even if someone has your passcode, they cannot recover that deleted photo. Even the most advanced forensic tools cannot ‘guess’ a deleted encryption key because the math behind it is designed to be unbreakable.
Hope that helps.