Saving several images in an app (not gallery) & auto crop


Hi, I am working on my first typescript ionic project. This time over, I am trying to make sure I use as few 3rd party plugins as possible and rely mostly on ionic-native interfaces to keep my code clean and easy to maintain. This is my first app, so I’m a newbie to the new formats/process of angular 2/3/4

I have two questions:

a) My app is an ‘image catalog manager’ - in other words, you take photos, tag them and my app files and saves them for a specific purpose. I don’t want these images to be saved in the photo gallery because that can be deleted outside of the app. I’d prefer to store it in_app. I’m using IonicStorage with cordova-sqlite. It looks like to save images, I need to base64encode them, which makes images much larger. I also read other posts there that its not good practice to store images in DBs if there are many. So what is the best practice that I can adopt? (Saving to camera gallery and just putting the path URL in the DB is not an option, due to reasons mentioned above). What if I save as a Blob instead of base64 ? Bad practice in DB?

b) Many apps (example banking apps) allow you to point a camera to an image, and it automatically detects borders and takes a photo without you having to tap on ‘take photo’ (useful for document cropping). How does one go about using this in the new ionic? Is there a way you can route it to ionic-native interface?



By DB do you mean a database? Because of course you can save photos to a database – you have to, if you don’t want to store them only locally. Facebook, Instagram, etc., do this all the time. It’s hard for me to understand what you could have read that said that was bad. It’s not a good idea to save photos to the Firebase realtime database, but there’s a service Firebase Storage specifically for that, and you can save Blobs there. I use that for a project, and I save Blobs there, not base64 strings.

I think you’d really benefit from reading a book and/or taking a course. I’m most familiar with Josh Morony’s book, which I liked, but there are other books too, and Ionic recently partnered with someone to produce a video course, see the Ionic blog. (And I think there’s a video course at EggheadIO also.) Give yourself a coherent foundation.


There are actually several discussions on the cons of storing many image in a DB. I was curious what folks here are doing. I am not sure how you concluded that FB and other apps store images in DB. Are you sure they are not storing in a filesystem path inside the app? (Yes DB == database)


You still didn’t say what “DB” means. Depending what it means, the answer is going to be yes or no. That’s why I think you need to read a book. Relying on an answer on SO that is flagged as a bad question is not going to get you very far.


I edited the answer to state DB = Database. Its standard terminology.

  1. You didn’t answer my question on how you assumed FB/Google etc store images in the DB
  2. Your comment on the SO thread is wrong - its flagged because it was ‘not appropriate for SO’ (i.e. usage depends on need), not because it was technically weak. There are excellent responses there.
  3. Read up a bit more - SO is not the only place where this is discussed - the pro/cons of in db image stores. You don’t really have to because I asked the question, but if you must answer on technical merits, it will help

I’m looking for objective experiences from devs who’ve implemented projects which involve storing many images in the apps - how do they do it, and their approach.


Again, it depends what database means. You seem to think that a database is one particular thing, and it isn’t. It depends fundamentally on the data structure involved. The implicit assumption in that SO question is that database means SQL database, but it doesn’t. (Though that was kinda reasonable to assume in 2012.) The Firebase database is NoSQL for example, and the SO question you posted includes a link to a description of the Haystacks data structure used by Facebook in their photo storage.

But if you want comments on storing all photos on the app, I think it’s fair to point out that unless your target user puts a high priority on secrecy, then the user experience you’d be providing is less than what people now expect from apps. People expect that they can “clear the cache” and still recover their personal data. So you need what would be understood by a user as “cloud storage,” or people might be unpleasantly surprised.


All good points. Indeed by DB I only meant a SQLite DB that I create in the context of the app and stored in the phone. I should have clarified.

More details:

  1. My app deals with patient data. Due to various HIPAA etc requirements there can’t be storage on the cloud unless the patient decides to make a copy on his personal cloud

  2. each user will end up storing around 10,000+ images over time (their device space might limit this)

  3. On your comment about clearing app cache - my understanding is that clears local storage not SQLite. I also believe deleting cache does not remove persistent files stored inside app context. Not sure if the latter assumption is accurate. I’ll have to try.

  4. If the user decides not to back up images to iCloud or google cloud and they delete their app they will lost the data. It’s their call

That being said what are the best storage strategies? There is a lot of index searching in my app and images are loaded only during rendering specific records. So I’d like to keep the app as snappy as possible.


I hear you about HIPAA. But on the other hand, a user stores 1,000 images of medical importance, the user’s 3 year old drops the phone in the toilet, and all those images are gone forever? You might want to include some opt-in to upload to a hospital’s medical record or something. It’s an area I’ve never worked in directly, so I don’t know the law, but from a data perspective, it seems like a fragile way to store critical information that might have been obtained over a period of years and cannot be replaced.

I don’t know the best storage scheme for a device-only photo gallery, but one criterion seems to be that it would all be in a single well-labeled folder, so a user could easily back up to a desktop computer if desired.