Trail-Sense icon indicating copy to clipboard operation
Trail-Sense copied to clipboard

Don't reduce map image size during cropping

Open kylecorry31 opened this issue 3 years ago • 2 comments
trafficstars

Instead, record the warping and apply them before displaying the map / using the projection

The goal would be that the original image is not modified by Trail Sense unless the user chooses to reduce map resolution.

If I must crop/warp the original image, then I would like to retain the image resolution as best as possible - figure out how photo editing apps crop/warp without causing out of memory exceptions. It's fine to save the cropped image as a WEBP version (respecting selected quality).

Options if I don't reduce the size:

Option 1

  • Save the point to point transform in the DB
  • Apply the transform the same way I'm doing rotation - so in both the projection and enhanced image view
  • This may have issues with the tile loading of the subsample scale view and may need to modify source library

Option 2

  • Divide the output image into tiles
  • For each tile, load the region of the source image (inverse transform, bounds)
  • Warp the source region onto the output tile
  • Add tile support to the enhanced image view (i.e. load tiles from multiple sources)

Option 3

  • The same as option 1, but on my custom tile layer which will probably be easier to modify. Requires #1345 to be done.

Option 4

  • Find an external library which supports affine cropping - I haven't been able to find any yet that don't reduce the resolution

Option 5

  • Instead of cropping the map, just have the user draw the outline
  • Apply the transform only to the projection, therefore displaying the unmodified map
  • Not sure if I like this, but I want to try this out since it is the easiest solution

I'm going to try out option 5 prior to releasing Photo Maps - that way if I figure out the improved cropping I could add that back in, instead of removing functionality (or I could map cropping a setting)

kylecorry31 avatar Nov 27 '21 15:11 kylecorry31

Could you clarify what did you mean by writing the word size: size in disk space or size in scale (how big image is).

jptrzy avatar Jun 08 '23 21:06 jptrzy

@jptrzy I've updated the description of this issue to clarify. By size, I meant both disk space and resolution (though cropping will inherently reduce that).

kylecorry31 avatar Jun 09 '23 10:06 kylecorry31

I'm wondering if this is relevant to the issue I'm having. I want to import a geospatial pdf, a fairly large (dimensionally) map which is sized 55mb. Whenever I import it, it always gets reduced to about 300kb, becoming unusably blurry. I've also tried making both larger and smaller versions of the same map (from the larger geotiff source, converted with gdal), which all get reduced in size to 300kb once imported. I'm able to properly open and view these pdfs in my pdf viewer app. The practice geospatial pdfs I made with caltopo seemed to import fine, but they are much smaller to begin with. Should I open this as a new ticket?

StarTroop avatar Jun 24 '25 02:06 StarTroop

I'm wondering if this is relevant to the issue I'm having. I want to import a geospatial pdf, a fairly large (dimensionally) map which is sized 55mb. Whenever I import it, it always gets reduced to about 300kb, becoming unusably blurry. I've also tried making both larger and smaller versions of the same map (from the larger geotiff source, converted with gdal), which all get reduced in size to 300kb once imported. I'm able to properly open and view these pdfs in my pdf viewer app. The practice geospatial pdfs I made with caltopo seemed to import fine, but they are much smaller to begin with. Should I open this as a new ticket?

Hi, have you tried turning off the reduce photo/pdf resolution settings in photo maps settings? If so, then yes I recommend logging a new issue using the bug template.

That's assuming you aren't cropping the image during import (which is this issue)

kylecorry31 avatar Jun 24 '25 09:06 kylecorry31

Hi, have you tried turning off the reduce photo/pdf resolution settings in photo maps settings? If so, then yes I recommend logging a new issue using the bug template.

That's assuming you aren't cropping the image during import (which is this issue)

Sorry, I didn't even realise there was such an option. I assumed this was a bug since the automatic reduction of 55mb to 300kb doesn't seem like a sensible default, IMO. I've disabled the resizing but now the app crashes whenever I try to open my maps, though that's clearly a separate issue.

StarTroop avatar Jun 24 '25 10:06 StarTroop

Hi, have you tried turning off the reduce photo/pdf resolution settings in photo maps settings? If so, then yes I recommend logging a new issue using the bug template. That's assuming you aren't cropping the image during import (which is this issue)

Sorry, I didn't even realise there was such an option. I assumed this was a bug since the automatic reduction of 55mb to 300kb doesn't seem like a sensible default, IMO. I've disabled the resizing but now the app crashes whenever I try to open my maps, though that's clearly a separate issue.

Yeah, that's a separate issue likely related to https://github.com/kylecorry31/Trail-Sense/issues/1345

If you can provide some details in a new bug report that will help me investigate, though it's likely that the image is too large for the device.

I went with a high reduction by default to support lower end devices and for the primary use case of using the camera to import the map. That reduction amount was derived from my testing across various devices.

kylecorry31 avatar Jun 24 '25 12:06 kylecorry31